package Server.Poker.PDK;

import common.routine.CommonDef;

public class PDKLogic_Server {

	int m_cbAllCardData[][] = new int[Constants.DDZ_PLAYER][Constants.MAX_COUNT];// 所有扑克
	int m_cbLandScoreCardData[] = new int[Constants.MAX_COUNT]; // 叫牌扑克
	int m_cbUserCardCount[] = new int[Constants.DDZ_PLAYER]; // 扑克数目
	int m_wBankerUser; // 地主玩家
	int m_lBankerOutCardCount; // 出牌次数
	tagStackHandCardInfo m_StackHandCardInfo = new tagStackHandCardInfo(); // 栈变量
	int m_bCurrentState; // 当前状态
	boolean m_bCallScore[] = new boolean[Constants.DDZ_PLAYER]; // 倒拉标识

	// 获取数值
	int GetCardValue(int cbCardData) {
		return cbCardData & Constants.MASK_VALUE;
	}

	// 获取花色
	int GetCardColor(int cbCardData) {
		return cbCardData & Constants.MASK_COLOR;
	}

	//////////////////////////////////////////////////////////////////////////
	// 静态变量

	// 扑克数据
	int m_cbCardData[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, // 方块
																											// A
																											// -
																											// K
			 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, // 梅花
																							// A
																							// -
																							// K
			0x21, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, // 红桃
																							// A
																							// -
																							// K
			0x31,0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, // 黑桃
																							// A
																							// -
																							// K
			};
	int m_cbCardData123A[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, // 方块
			// A
			// -
			// K
			0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, // 梅花
			// A
			// -
			// K
			0x21, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, // 红桃
			// A
			// -
			// K
			0x31,0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, // 黑桃
			// A
			// -
			// K
	};
	int m_cbCardData4A[] = { 0x01, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, // 方块
			// A
			// -
			// K
			0x11,0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, // 梅花
			// A
			// -
			// K
			0x21, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, // 红桃
			// A
			// -
			// K
			0x31,0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, // 黑桃
			// A
			// -
			// K
	};
	int m_cbGoodcardData[] = { 0x01, 0x02, 0x11, 0x12, 0x21, 0x22, 0x31, 0x32, 0x4E, 0x4F, 0x07, 0x08, 0x09, 0x17, 0x18,
			0x19, 0x27, 0x28, 0x29, 0x37, 0x38, 0x39, 0x0A, 0x0B, 0x0C, 0x0D, 0x1A, 0x1B, 0x1C, 0x1D, 0x2A, 0x2B, 0x2C,
			0x2D, 0x3A, 0x3B, 0x3C, 0x3D };

	//////////////////////////////////////////////////////////////////////////

	// 构造函数
	public PDKLogic_Server() {
		// AI变量
		m_lBankerOutCardCount = 0;
		m_bCurrentState = 0;
		Constants.ZeroMemory(m_bCallScore);
	}
	public int GetPaiEvaluateScore(int[] cbHandCardData,int cbCardCount){
		int sumscore = 0;
		// 分析扑克
		tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();
		AnalysebCardData(cbHandCardData, cbCardCount, AnalyseResult);

		// 四牌
		sumscore += AnalyseResult.cbFourCount * 10;//炸弹10分

		// 三牌
		sumscore += AnalyseResult.cbThreeCount * 5;//三个5分

		// 对牌
		sumscore += AnalyseResult.cbDoubleCount * 2;//对2分

		// 单牌
		sumscore += AnalyseResult.cbSignedCount * -5;//每个单牌-5分
		// 判断大牌，每个8分
		for(int i = 0;i < cbCardCount;i++){
			if(GetCardLogicValue(cbHandCardData[i]) >= 15)
				sumscore += 8;
		}
		return sumscore;
	}
	private int GetCardType(int[] cbHandCardData, int i, int cbCardCount) {
		cbHandCardData = Constants.ArrayAdd(cbHandCardData, i);
		return GetCardType(cbHandCardData, cbCardCount);
	}

	// 获取类型
	int GetCardType(int cbCardData[], int cbCardCount) {
		// 简单牌型
		switch (cbCardCount) {
		case 0: // 空牌
		{
			return Constants.CT_ERROR;
		}
		case 1: // 单牌
		{
			return Constants.CT_SINGLE;
		}
		case 2: // 对牌火箭
		{
			// 牌型判断
			if ((cbCardData[0] == 0x4F) && (cbCardData[1] == 0x4E))
				return Constants.CT_MISSILE_CARD;
			if (GetCardLogicValue(cbCardData[0]) == GetCardLogicValue(cbCardData[1]))
				return Constants.CT_DOUBLE;

			return Constants.CT_ERROR;
		}
		}

		// 分析扑克
		tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();
		if (!AnalysebCardData(cbCardData, cbCardCount, AnalyseResult))
			return Constants.CT_ERROR;

		// 四牌判断
		if (AnalyseResult.cbFourCount > 0) {
			// 牌型判断
			if ((AnalyseResult.cbFourCount == 1) && (cbCardCount == 4))
				return Constants.CT_BOMB_CARD;
			if ((AnalyseResult.cbFourCount == 1) && (AnalyseResult.cbSignedCount == 2) && (cbCardCount == 6))
				return Constants.CT_FOUR_LINE_TAKE_ONE;
			
			// if
			// ((AnalyseResult.cbFourCount==1)&&(AnalyseResult.cbDoubleCount==1)&&(cbCardCount==6))
			// return CT_FOUR_LINE_TAKE_ONE;
			if ((AnalyseResult.cbFourCount == 1) && (AnalyseResult.cbDoubleCount == 2) && (cbCardCount == 8))
				return Constants.CT_FOUR_LINE_TAKE_TWO;
			
			
			

			return Constants.CT_ERROR;
		}

		// 三牌判断
		if (AnalyseResult.cbThreeCount > 0) {
			// 三条类型
			if (AnalyseResult.cbThreeCount == 1 && cbCardCount == 3)
				return Constants.CT_THREE;

			// 连牌判断
			if (AnalyseResult.cbThreeCount > 1) {
				// 变量定义
				int cbCardData1 = AnalyseResult.cbThreeCardData[0];
				int cbFirstLogicValue = GetCardLogicValue(cbCardData1);

				// 错误过虑
				if (cbFirstLogicValue >= 15)
					return Constants.CT_ERROR;

				// 连牌判断
				for (int i = 1; i < AnalyseResult.cbThreeCount; i++) {
					int cbCardData11 = AnalyseResult.cbThreeCardData[i * 3];
					if (cbFirstLogicValue != (GetCardLogicValue(cbCardData11) + i))
						return Constants.CT_ERROR;
				}
			}

			// 牌形判断
			if (AnalyseResult.cbThreeCount * 3 == cbCardCount)
				return Constants.CT_THREE_LINE;
			if (AnalyseResult.cbThreeCount * 4 == cbCardCount)
				return Constants.CT_THREE_LINE_TAKE_ONE;
			if ((AnalyseResult.cbThreeCount * 5 == cbCardCount)
					&& (AnalyseResult.cbDoubleCount == AnalyseResult.cbThreeCount))
				return Constants.CT_THREE_LINE_TAKE_TWO;
			
			if ((AnalyseResult.cbThreeCount == 1) && (AnalyseResult.cbSignedCount == 2) && (cbCardCount == 5))
				return Constants.CT_THREE_LINE_TAKE_TWO_ONE;

			return Constants.CT_ERROR;
		}

		// 两张类型
		if (AnalyseResult.cbDoubleCount >= 2) {
			// 变量定义
			int cbCardData1 = AnalyseResult.cbDoubleCardData[0];
			int cbFirstLogicValue = GetCardLogicValue(cbCardData1);

			// 错误过虑
			if (cbFirstLogicValue >= 15)
				return Constants.CT_ERROR;

			// 连牌判断
			for (int i = 1; i < AnalyseResult.cbDoubleCount; i++) {
				int cbCardData11 = AnalyseResult.cbDoubleCardData[i * 2];
				if (cbFirstLogicValue != (GetCardLogicValue(cbCardData11) + i))
					return Constants.CT_ERROR;
			}

			// 二连判断
			if ((AnalyseResult.cbDoubleCount * 2) == cbCardCount)
				return Constants.CT_DOUBLE_LINE;

			return Constants.CT_ERROR;
		}

		// 单张判断
		if ((AnalyseResult.cbSignedCount >= 5) && (AnalyseResult.cbSignedCount == cbCardCount)) {
			// 变量定义
			int cbCardData1 = AnalyseResult.cbSignedCardData[0];
			int cbFirstLogicValue = GetCardLogicValue(cbCardData1);

			// 错误过虑
			if (cbFirstLogicValue >= 15)
				return Constants.CT_ERROR;

			// 连牌判断
			for (int i = 1; i < AnalyseResult.cbSignedCount; i++) {
				int cbCardData11 = AnalyseResult.cbSignedCardData[i];
				if (cbFirstLogicValue != (GetCardLogicValue(cbCardData11) + i))
					return Constants.CT_ERROR;
			}

			return Constants.CT_SINGLE_LINE;
		}

		return Constants.CT_ERROR;
	}

	// 排列扑克
	void SortCardList(int cbCardData[], int cbCardCount, int cbSortType) {
		// 数目过虑
		if (cbCardCount == 0)
			return;

		// 转换数值
		int cbSortValue[] = new int[Constants.MAX_COUNT];
		for (int i = 0; i < cbCardCount; i++) {
			cbSortValue[i] = GetCardLogicValue(cbCardData[i]);
		}

		// 排序操作
		boolean bSorted = true;
		int cbThreeCount, cbLast = cbCardCount - 1;
		do {
			bSorted = true;
			for (int i = 0; i < cbLast; i++) {
				if ((cbSortValue[i] < cbSortValue[i + 1])
						|| ((cbSortValue[i] == cbSortValue[i + 1]) && (cbCardData[i] < cbCardData[i + 1]))) {
					// 交换位置
					cbThreeCount = cbCardData[i];
					cbCardData[i] = cbCardData[i + 1];
					cbCardData[i + 1] = cbThreeCount;
					cbThreeCount = cbSortValue[i];
					cbSortValue[i] = cbSortValue[i + 1];
					cbSortValue[i + 1] = cbThreeCount;
					bSorted = false;
				}
			}
			cbLast--;
		} while (bSorted == false);

		// 数目排序
		if (cbSortType == Constants.ST_COUNT) {
			// 分析扑克
			int cbIndex = 0;
			tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();
			AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);

			// 拷贝四牌
			Constants.CopyMemory(cbCardData,cbIndex, AnalyseResult.cbFourCardData, AnalyseResult.cbFourCount * 4);
			cbIndex += AnalyseResult.cbFourCount * 4;

			// 拷贝三牌
			Constants.CopyMemory(cbCardData,cbIndex, AnalyseResult.cbThreeCardData, AnalyseResult.cbThreeCount * 3);
			cbIndex += AnalyseResult.cbThreeCount * 3;

			// 拷贝对牌
			Constants.CopyMemory(cbCardData,cbIndex, AnalyseResult.cbDoubleCardData, AnalyseResult.cbDoubleCount * 2);
			cbIndex += AnalyseResult.cbDoubleCount * 2;

			// 拷贝单牌
			Constants.CopyMemory(cbCardData,cbIndex, AnalyseResult.cbSignedCardData, AnalyseResult.cbSignedCount);
			cbIndex += AnalyseResult.cbSignedCount;
		}

		return;
	}

	// 得到好牌
	void GetGoodCardData(int cbGoodCardData[]) {
		// 混乱准备
		int cbCardData[] = new int[Constants.CountArray(m_cbGoodcardData)];
		int cbCardBuffer[] = new int[Constants.CountArray(m_cbGoodcardData)];
		Constants.CopyMemory(cbCardData, m_cbGoodcardData, Constants.sizeof(m_cbGoodcardData));

		// 混乱扑克
		int cbRandCount = 0, cbPosition = 0;
		int cbBufferCount = Constants.CountArray(m_cbGoodcardData);
		do {
			if (cbBufferCount - cbRandCount == 0)
				return;
			cbPosition = Constants.rand() % (cbBufferCount - cbRandCount);
			cbCardBuffer[cbRandCount++] = cbCardData[cbPosition];
			cbCardData[cbPosition] = cbCardData[cbBufferCount - cbRandCount];
		} while (cbRandCount < cbBufferCount);

		// 复制好牌
		Constants.CopyMemory(cbGoodCardData, cbCardBuffer, Constants.NORMAL_COUNT);
	}

	// 删除好牌
	boolean RemoveGoodCardData(int cbGoodcardData[], int cbGoodCardCount, int cbCardData[], int cbCardCount) {

		// 定义变量
		int cbDeleteCount = 0;
		int cbTempCardData[] = new int[Constants.FULL_COUNT];
		if (cbCardCount > Constants.CountArray(cbTempCardData))
			return false;
		Constants.CopyMemory(cbTempCardData, cbCardData, cbCardCount);

		// 置零扑克
		for (int i = 0; i < cbGoodCardCount; i++) {
			for (int j = 0; j < cbCardCount; j++) {
				if (cbGoodcardData[i] == cbTempCardData[j]) {
					cbDeleteCount++;
					cbTempCardData[j] = 0;
					break;
				}
			}
		}
		if (cbDeleteCount != cbGoodCardCount)
			return false;

		// 清理扑克
		int cbCardPos = 0;
		for (int i = 0; i < cbCardCount; i++) {
			if (cbTempCardData[i] != 0)
				cbCardData[cbCardPos++] = cbTempCardData[i];
		}

		return true;
	}

	// 混乱扑克
	void RandCardList(int cbCardBuffer[], int cbBufferCount,int usepai) {
		if(usepai == 0){//123A
			// 混乱准备
			int cbCardData[] = new int[Constants.CountArray(m_cbCardData123A)];
			Constants.CopyMemory(cbCardData, m_cbCardData123A, Constants.sizeof(m_cbCardData123A));
	
			// 混乱扑克
			int cbRandCount = 0, cbPosition = 0;
			do {
				cbPosition = Constants.rand() % (cbBufferCount - cbRandCount);
	
				cbCardBuffer[cbRandCount++] = cbCardData[cbPosition];
				cbCardData[cbPosition] = cbCardData[cbBufferCount - cbRandCount];
				cbCardData[cbBufferCount - cbRandCount] = 0;
			} while (cbRandCount < cbBufferCount);
		}else{//4A
			// 混乱准备
			int cbCardData[] = new int[Constants.CountArray(m_cbCardData4A)];
			Constants.CopyMemory(cbCardData, m_cbCardData4A, Constants.sizeof(m_cbCardData4A));
	
			// 混乱扑克
			int cbRandCount = 0, cbPosition = 0;
			do {
				cbPosition = Constants.rand() % (cbBufferCount - cbRandCount);
	
				cbCardBuffer[cbRandCount++] = cbCardData[cbPosition];
				cbCardData[cbPosition] = cbCardData[cbBufferCount - cbRandCount];
				cbCardData[cbBufferCount - cbRandCount] = 0;
			} while (cbRandCount < cbBufferCount);
		}
		return;
	}

	// 删除扑克
	boolean RemoveCard(int cbRemoveCard[], int cbRemoveCount, int cbCardData[], int cbCardCount) {

		// 定义变量
		int cbDeleteCount = 0;
		int cbTempCardData[] = new int[Constants.MAX_COUNT];
		if (cbCardCount > Constants.CountArray(cbTempCardData))
			return false;
		Constants.CopyMemory(cbTempCardData, cbCardData, cbCardCount);

		// 置零扑克
		for (int i = 0; i < cbRemoveCount; i++) {
			for (int j = 0; j < cbCardCount; j++) {
				if (cbRemoveCard[i] == cbTempCardData[j]) {
					cbDeleteCount++;
					cbTempCardData[j] = 0;
					break;
				}
			}
		}
		if (cbDeleteCount != cbRemoveCount)
			return false;

		// 清理扑克
		int cbCardPos = 0;
		for (int i = 0; i < cbCardCount; i++) {
			if (cbTempCardData[i] != 0)
				cbCardData[cbCardPos++] = cbTempCardData[i];
		}
		for(int i = cbCardCount;i < cbCardData.length;i++)
			cbCardData[i] = 0;
		return true;
	}

	// 有效判断
	boolean IsValidCard(int cbCardData) {
		// 获取属性
		int cbCardColor = GetCardColor(cbCardData);
		int cbCardValue = GetCardValue(cbCardData);

		// 有效判断
		if ((cbCardData == 0x4E) || (cbCardData == 0x4F))
			return true;
		if ((cbCardColor <= 0x30) && (cbCardValue >= 0x01) && (cbCardValue <= 0x0D))
			return true;

		return false;
	}

	// 逻辑数值
	int GetCardLogicValue(int cbCardData) {
		if (!IsValidCard(cbCardData))
			return 0;
		// 扑克属性
		int cbCardColor = GetCardColor(cbCardData);
		int cbCardValue = GetCardValue(cbCardData);

		// 转换数值
		if (cbCardColor == 0x40)
			return cbCardValue + 2;
		return (cbCardValue <= 2) ? (cbCardValue + 13) : cbCardValue;
	}

	// 对比扑克
	boolean CompareCard(int cbFirstCard[], int cbNextCard[], int cbFirstCount, int cbNextCount) {
		// 获取类型
		int cbNextType = GetCardType(cbNextCard, cbNextCount);
		int cbFirstType = GetCardType(cbFirstCard, cbFirstCount);

		// 类型判断
		if (cbNextType == Constants.CT_ERROR)
			return false;
		if (cbNextType == Constants.CT_MISSILE_CARD)
			return true;
		if (cbFirstType == Constants.CT_MISSILE_CARD)
			return false;

		// 炸弹判断
		if ((cbFirstType != Constants.CT_BOMB_CARD) && (cbNextType == Constants.CT_BOMB_CARD))
			return true;
		if ((cbFirstType == Constants.CT_BOMB_CARD) && (cbNextType != Constants.CT_BOMB_CARD))
			return false;

		// 规则判断
		if ((cbFirstType != cbNextType) || (cbFirstCount != cbNextCount))
			return false;

		// 开始对比
		switch (cbNextType) {
		case Constants.CT_SINGLE:
		case Constants.CT_DOUBLE:
		case Constants.CT_THREE:
		case Constants.CT_SINGLE_LINE:
		case Constants.CT_DOUBLE_LINE:
		case Constants.CT_THREE_LINE:
		case Constants.CT_BOMB_CARD: {
			// 获取数值
			int cbNextLogicValue = GetCardLogicValue(cbNextCard[0]);
			int cbFirstLogicValue = GetCardLogicValue(cbFirstCard[0]);

			// 对比扑克
			return cbNextLogicValue > cbFirstLogicValue;
		}
		case Constants.CT_THREE_LINE_TAKE_ONE:
		case Constants.CT_THREE_LINE_TAKE_TWO_ONE:
		case Constants.CT_THREE_LINE_TAKE_TWO: {
			// 分析扑克
			tagAnalyseResult_Server NextResult = new tagAnalyseResult_Server();
			tagAnalyseResult_Server FirstResult = new tagAnalyseResult_Server();
			AnalysebCardData(cbNextCard, cbNextCount, NextResult);
			AnalysebCardData(cbFirstCard, cbFirstCount, FirstResult);

			// 获取数值
			int cbNextLogicValue = GetCardLogicValue(NextResult.cbThreeCardData[0]);
			int cbFirstLogicValue = GetCardLogicValue(FirstResult.cbThreeCardData[0]);

			// 对比扑克
			return cbNextLogicValue > cbFirstLogicValue;
		}
		case Constants.CT_FOUR_LINE_TAKE_ONE:
		case Constants.CT_FOUR_LINE_TAKE_TWO: {
			// 分析扑克
			tagAnalyseResult_Server NextResult = new tagAnalyseResult_Server();
			tagAnalyseResult_Server FirstResult = new tagAnalyseResult_Server();
			AnalysebCardData(cbNextCard, cbNextCount, NextResult);
			AnalysebCardData(cbFirstCard, cbFirstCount, FirstResult);

			// 获取数值
			int cbNextLogicValue = GetCardLogicValue(NextResult.cbFourCardData[0]);
			int cbFirstLogicValue = GetCardLogicValue(FirstResult.cbFourCardData[0]);

			// 对比扑克
			return cbNextLogicValue > cbFirstLogicValue;
		}
		}

		return false;
	}

	// 分析扑克
	boolean AnalysebCardData(int cbCardData[], int cbCardCount, tagAnalyseResult_Server AnalyseResult) {

		// 扑克分析
		for (int i = 0; i < cbCardCount; i++) {
			// 变量定义
			int cbSameCount = 1;
			int cbLogicValue = GetCardLogicValue(cbCardData[i]);
			if (cbLogicValue <= 0)
				return false;

			// 搜索同牌
			for (int j = i + 1; j < cbCardCount; j++) {
				// 获取扑克
				if (GetCardLogicValue(cbCardData[j]) != cbLogicValue)
					break;

				// 设置变量
				cbSameCount++;
			}

			// 设置结果
			switch (cbSameCount) {
			case 1: // 单张
			{
				int cbIndex = AnalyseResult.cbSignedCount++;
				AnalyseResult.cbSignedCardData[cbIndex * cbSameCount] = cbCardData[i];
				break;
			}
			case 2: // 两张
			{
				int cbIndex = AnalyseResult.cbDoubleCount++;
				AnalyseResult.cbDoubleCardData[cbIndex * cbSameCount] = cbCardData[i];
				AnalyseResult.cbDoubleCardData[cbIndex * cbSameCount + 1] = cbCardData[i + 1];
				break;
			}
			case 3: // 三张
			{
				int cbIndex = AnalyseResult.cbThreeCount++;
				AnalyseResult.cbThreeCardData[cbIndex * cbSameCount] = cbCardData[i];
				AnalyseResult.cbThreeCardData[cbIndex * cbSameCount + 1] = cbCardData[i + 1];
				AnalyseResult.cbThreeCardData[cbIndex * cbSameCount + 2] = cbCardData[i + 2];
				break;
			}
			case 4: // 四张
			{
				int cbIndex = AnalyseResult.cbFourCount++;
				AnalyseResult.cbFourCardData[cbIndex * cbSameCount] = cbCardData[i];
				AnalyseResult.cbFourCardData[cbIndex * cbSameCount + 1] = cbCardData[i + 1];
				AnalyseResult.cbFourCardData[cbIndex * cbSameCount + 2] = cbCardData[i + 2];
				AnalyseResult.cbFourCardData[cbIndex * cbSameCount + 3] = cbCardData[i + 3];
				break;
			}
			}

			// 设置索引
			i += cbSameCount - 1;
		}

		return true;
	}

	// 随机扑克
	int GetRandomCard() {
		int cbIndex = Constants.rand() % (Constants.sizeof(m_cbCardData));
		return m_cbCardData[cbIndex];
	}

	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//// 以下为AI函数
	//测试函数
	void testSearch(){
		int cbHandCardData[] = {2, 49, 33, 45, 59, 27, 11, 26, 10, 23, 22, 6, 21, 36, 51, 3, 0, 0, 0, 0};
		int cbHandCardCount = 16;
		tagOutCardTypeResult_Server CardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
		tagOutCardTypeResult_Server.init(CardTypeResult);
		int cbLineCard[] = new int[Constants.MAX_COUNT];
		int cbThreeLineCard[] = new int[Constants.MAX_COUNT];
		int cbDoubleLineCard[] = new int[Constants.MAX_COUNT];
		int cbLineCardCount = 0;
		int cbThreeLineCardCount = 0;
		int cbDoubleLineCount = 0;
		cbLineCardCount = GetAllLineCard(cbHandCardData, cbHandCardCount, cbLineCard, cbLineCardCount);
		cbThreeLineCardCount = GetAllThreeCard(cbHandCardData, cbHandCardCount, cbThreeLineCard, cbThreeLineCardCount);
		cbDoubleLineCount = GetAllDoubleCard(cbHandCardData, cbHandCardCount, cbDoubleLineCard, cbDoubleLineCount);

		int wUndersideOfBanker = (m_wBankerUser + 1) % Constants.DDZ_PLAYER; // 地主下家
		int wUpsideOfBanker = (wUndersideOfBanker + 1) % Constants.DDZ_PLAYER; // 地主上家

		// 判断可否出完
		int cbSingleCardCount = Constants.MAX_COUNT + Constants.CT_MISSILE_CARD;
		boolean bFindBestCard = false;
		AnalyseOutCardType(cbHandCardData, cbHandCardCount, CardTypeResult);
		int a = 0;
	}
	// 出牌搜索
	boolean SearchOutCard(int cbHandCardData[], int cbHandCardCount, int cbTurnCardData[], int cbTurnCardCount,
			int wOutCardUser, int wMeChairID, tagOutCardResult_Server OutCardResult,int[] robotSign) {
		// 玩家判断,附加判断自己的下家是否是地主，并且地主是否跟自己都是机器人
		//m_wBankerUser = wMeChairID;
		int wUndersideOfBanker = (m_wBankerUser + 1) % Constants.DDZ_PLAYER; // 地主下家
		int wUpsideOfBanker = (wUndersideOfBanker + 1) % Constants.DDZ_PLAYER; // 地主上家
		int nextIsRobot = robotSign[(wMeChairID + 1) % Constants.DDZ_PLAYER];
		//m_wBankerUser %= Constants.DDZ_PLAYER;
		// 先出牌
		if (cbTurnCardCount == 0) {
			if (wMeChairID == m_wBankerUser){
				// 地主出牌
				if(nextIsRobot == 1)
					BankerOutCard(cbHandCardData, cbHandCardCount, OutCardResult);
				else
					UpsideOfBankerOutCard(cbHandCardData, cbHandCardCount, wMeChairID, OutCardResult);
		
			}else if (wMeChairID == wUndersideOfBanker){
				// 地主下家hack
				if(CommonDef.getRandomInt(100) > 20){
					if(nextIsRobot == 1){
						//下家是机器人
						UndersideOfBankerOutCard(cbHandCardData, cbHandCardCount, wMeChairID, OutCardResult);
					}else{
						//下家是真人
						UpsideOfBankerOutCard(cbHandCardData, cbHandCardCount, wMeChairID, OutCardResult);
					}
				}else{
					UndersideOfBankerOutCard(cbHandCardData, cbHandCardCount, wMeChairID, OutCardResult);
				}
			}else if (wMeChairID == wUpsideOfBanker){
				// 地主上家hack
				if(CommonDef.getRandomInt(100) > 20){
					if(nextIsRobot == 1){
						//下家是机器人
						UndersideOfBankerOutCard(cbHandCardData, cbHandCardCount, wMeChairID, OutCardResult);
					}else{
						UpsideOfBankerOutCard(cbHandCardData, cbHandCardCount, wMeChairID, OutCardResult);					
					}
				}else{
					UpsideOfBankerOutCard(cbHandCardData, cbHandCardCount, wMeChairID, OutCardResult);	
				}
			}
			// 错误 ID
			//BankerOutCard(cbHandCardData, cbHandCardCount, OutCardResult);
		}
		// 压牌
		else {
			if (wMeChairID == m_wBankerUser){
				// 地主出牌
				if(nextIsRobot == 1)
					BankerOutCard(cbHandCardData, cbHandCardCount, wOutCardUser, cbTurnCardData, cbTurnCardCount,
						OutCardResult);
				else
					UpsideOfBankerOutCard(cbHandCardData, cbHandCardCount, wOutCardUser, cbTurnCardData, cbTurnCardCount,
							OutCardResult);
			}else if (wMeChairID == wUndersideOfBanker){
				// 地主下家
				if(nextIsRobot == 1){
					UndersideOfBankerOutCard(cbHandCardData, cbHandCardCount, wOutCardUser, cbTurnCardData, cbTurnCardCount,
							OutCardResult);
				}else{
					UpsideOfBankerOutCard(cbHandCardData, cbHandCardCount, wOutCardUser, cbTurnCardData, cbTurnCardCount,
							OutCardResult);
				}
			}else if (wMeChairID == wUpsideOfBanker){
				// 地主上家
				if(nextIsRobot == 1){
					UndersideOfBankerOutCard(cbHandCardData, cbHandCardCount, wOutCardUser, cbTurnCardData, cbTurnCardCount,
							OutCardResult);
				}else{
					if(CommonDef.getRandomInt(100) > 60)
						UpsideOfBankerOutCard(cbHandCardData, cbHandCardCount, wOutCardUser, cbTurnCardData, cbTurnCardCount,
							OutCardResult);
					else
						UndersideOfBankerOutCard(cbHandCardData, cbHandCardCount, wOutCardUser, cbTurnCardData, cbTurnCardCount,
							OutCardResult);
				}
			}
			// 错误 ID
			//BankerOutCard(cbHandCardData, cbHandCardCount, wOutCardUser, cbTurnCardData, cbTurnCardCount,	OutCardResult);
			// 反春天判断
			if (GetCardType(m_cbAllCardData[wOutCardUser], m_cbUserCardCount[wOutCardUser]) != Constants.CT_ERROR
					&& m_lBankerOutCardCount == 1 && (OutCardResult.cbCardCount <= 0 || !CompareCard(cbTurnCardData,
							OutCardResult.cbResultCard, cbTurnCardCount, OutCardResult.cbCardCount))) {
				// 零下标没用
				tagOutCardTypeResult_Server CardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
				tagOutCardTypeResult_Server.init(CardTypeResult);
				// 出牌类型
				AnalyseOutCardType(cbHandCardData, cbHandCardCount, cbTurnCardData, cbTurnCardCount, CardTypeResult);

				int cbOutCardType = GetCardType(cbTurnCardData, cbTurnCardCount);

				if (CardTypeResult[cbOutCardType].cbCardTypeCount > 0 && cbOutCardType != Constants.CT_THREE) {
					int cbIndex = CardTypeResult[cbOutCardType].cbCardTypeCount - 1;
					int cbCardCount = CardTypeResult[cbOutCardType].cbEachHandCardCount[cbIndex];

					Constants.CopyMemory(OutCardResult.cbResultCard, CardTypeResult[cbOutCardType].cbCardData[cbIndex],
							cbCardCount);
					OutCardResult.cbCardCount = cbCardCount;
				}
				// 出炸弹
				else if (CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount > 0) {
					int cbIndex = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount - 1;
					int cbCardCount = CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[cbIndex];
					Constants.CopyMemory(OutCardResult.cbResultCard,
							CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[cbIndex], cbCardCount);
					OutCardResult.cbCardCount = cbCardCount;
				} else if (CardTypeResult[Constants.CT_MISSILE_CARD].cbCardTypeCount > 0) {
					OutCardResult.cbCardCount = 2;
					OutCardResult.cbResultCard[0] = 0x4F;
					OutCardResult.cbResultCard[1] = 0x4E;
				}
			}

			// 春天判断
			if (GetCardType(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser]) != Constants.CT_ERROR
					&& (OutCardResult.cbCardCount <= 0 || !CompareCard(cbTurnCardData, OutCardResult.cbResultCard,
							cbTurnCardCount, OutCardResult.cbCardCount))
					&& m_cbUserCardCount[(1 + m_wBankerUser) % Constants.DDZ_PLAYER] == Constants.NORMAL_COUNT
					&& m_cbUserCardCount[(2 + m_wBankerUser) % Constants.DDZ_PLAYER] == Constants.NORMAL_COUNT) {
				// 零下标没用
				tagOutCardTypeResult_Server CardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
				tagOutCardTypeResult_Server.init(CardTypeResult);
				// 出牌类型
				AnalyseOutCardType(cbHandCardData, cbHandCardCount, cbTurnCardData, cbTurnCardCount, CardTypeResult);

				int cbOutCardType = GetCardType(cbTurnCardData, cbTurnCardCount);

				if (CardTypeResult[cbOutCardType].cbCardTypeCount > 0 && cbOutCardType != Constants.CT_THREE) {
					int cbIndex = CardTypeResult[cbOutCardType].cbCardTypeCount - 1;
					int cbCardCount = CardTypeResult[cbOutCardType].cbEachHandCardCount[cbIndex];

					Constants.CopyMemory(OutCardResult.cbResultCard, CardTypeResult[cbOutCardType].cbCardData[cbIndex],
							cbCardCount);
					OutCardResult.cbCardCount = cbCardCount;
				}
				// 出炸弹
				else if (CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount > 0) {
					int cbIndex = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount - 1;
					int cbCardCount = CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[cbIndex];
					Constants.CopyMemory(OutCardResult.cbResultCard,
							CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[cbIndex], cbCardCount);
					OutCardResult.cbCardCount = cbCardCount;
				} else if (CardTypeResult[Constants.CT_MISSILE_CARD].cbCardTypeCount > 0) {
					OutCardResult.cbCardCount = 2;
					OutCardResult.cbResultCard[0] = 0x4F;
					OutCardResult.cbResultCard[1] = 0x4E;
				}
			}

		}

		// 出牌次数
		if (m_wBankerUser == wMeChairID && OutCardResult.cbCardCount > 0)
			++m_lBankerOutCardCount;

		return true;
	}

	private int GetAllBomCard(int[] cbHandCardData, int cbHandCardCount, int j, int[] cbBomCardData,
			int cbBomCardCount) {
		cbHandCardData = Constants.ArrayAdd(cbHandCardData, j);
		return GetAllBomCard(cbHandCardData, cbHandCardCount, cbBomCardData, cbBomCardCount);
	}

	// 分析炸弹
	int GetAllBomCard(int cbHandCardData[], int cbHandCardCount, int cbBomCardData[], int cbBomCardCount) {
		int cbTmpCardData[] = new int[Constants.MAX_COUNT];
		Constants.CopyMemory(cbTmpCardData, cbHandCardData, cbHandCardCount);

		// 大小排序
		SortCardList(cbTmpCardData, cbHandCardCount, Constants.ST_ORDER);

		cbBomCardCount = 0;

		if (cbHandCardCount < 2)
			return 0;

		// 双王炸弹
		if (0x4F == cbTmpCardData[0] && 0x4E == cbTmpCardData[1]) {
			cbBomCardData[cbBomCardCount++] = cbTmpCardData[0];
			cbBomCardData[cbBomCardCount++] = cbTmpCardData[1];
		}

		// 扑克分析
		for (int i = 0; i < cbHandCardCount; i++) {
			// 变量定义
			int cbSameCount = 1;
			int cbLogicValue = GetCardLogicValue(cbTmpCardData[i]);

			// 搜索同牌
			for (int j = i + 1; j < cbHandCardCount; j++) {
				// 获取扑克
				if (GetCardLogicValue(cbTmpCardData[j]) != cbLogicValue)
					break;

				// 设置变量
				cbSameCount++;
			}

			if (4 == cbSameCount) {
				cbBomCardData[cbBomCardCount++] = cbTmpCardData[i];
				cbBomCardData[cbBomCardCount++] = cbTmpCardData[i + 1];
				cbBomCardData[cbBomCardCount++] = cbTmpCardData[i + 2];
				cbBomCardData[cbBomCardCount++] = cbTmpCardData[i + 3];
			}

			// 设置索引
			i += cbSameCount - 1;
		}
		return cbBomCardCount;
	}

	// 分析顺子
	int GetAllLineCard(int cbHandCardData[], int cbHandCardCount, int cbLineCardData[], int cbLineCardCount) {
		int cbTmpCard[] = new int[Constants.MAX_COUNT];
		Constants.CopyMemory(cbTmpCard, cbHandCardData, cbHandCardCount);
		// 大小排序
		SortCardList(cbTmpCard, cbHandCardCount, Constants.ST_ORDER);

		cbLineCardCount = 0;

		// 数据校验
		if (cbHandCardCount < 5)
			return 0;

		int cbFirstCard = 0;
		// 去除2和王
		for (int i = 0; i < cbHandCardCount; ++i)
			if (GetCardLogicValue(cbTmpCard[i]) < 15) {
				cbFirstCard = i;
				break;
			}

		int cbSingleLineCard[] = new int[12];
		int cbSingleLineCount = 0;
		int cbLeftCardCount = cbHandCardCount;
		boolean bFindSingleLine = true;

		// 连牌判断
		while (cbLeftCardCount >= 5 && bFindSingleLine) {
			cbSingleLineCount = 1;
			bFindSingleLine = false;
			int cbLastCard = cbTmpCard[cbFirstCard];
			cbSingleLineCard[cbSingleLineCount - 1] = cbTmpCard[cbFirstCard];
			for (int i = cbFirstCard + 1; i < cbLeftCardCount; i++) {
				int cbCardData = cbTmpCard[i];

				// 连续判断
				if (1 != (GetCardLogicValue(cbLastCard) - GetCardLogicValue(cbCardData))
						&& GetCardValue(cbLastCard) != GetCardValue(cbCardData)) {
					cbLastCard = cbTmpCard[i];
					if (cbSingleLineCount < 5) {
						cbSingleLineCount = 1;
						cbSingleLineCard[cbSingleLineCount - 1] = cbTmpCard[i];
						continue;
					} else
						break;
				}
				// 同牌判断
				else if (GetCardValue(cbLastCard) != GetCardValue(cbCardData)) {
					cbLastCard = cbCardData;
					cbSingleLineCard[cbSingleLineCount] = cbCardData;
					++cbSingleLineCount;
				}
			}

			// 保存数据
			if (cbSingleLineCount >= 5) {
				RemoveCard(cbSingleLineCard, cbSingleLineCount, cbTmpCard, cbLeftCardCount);
				Constants.memcpy(cbLineCardData, cbLineCardCount, cbSingleLineCard, cbSingleLineCount);
				cbLineCardCount += cbSingleLineCount;
				cbLeftCardCount -= cbSingleLineCount;
				bFindSingleLine = true;
			}
		}
		return cbLineCardCount;
	}

	private int GetAllThreeCard(int[] cbTmpCard, int cbFirstCard, int i, int[] cbHandThreeCard, int cbHandThreeCount) {
		cbTmpCard = Constants.ArrayAdd(cbTmpCard, cbFirstCard);
		return GetAllThreeCard(cbTmpCard, i, cbHandThreeCard, cbHandThreeCount);
	}

	// 分析三条
	int GetAllThreeCard(int cbHandCardData[], int cbHandCardCount, int cbThreeCardData[], int cbThreeCardCount) {
		int cbTmpCardData[] = new int[Constants.MAX_COUNT];
		Constants.CopyMemory(cbTmpCardData, cbHandCardData, cbHandCardCount);

		// 大小排序
		SortCardList(cbTmpCardData, cbHandCardCount, Constants.ST_ORDER);

		cbThreeCardCount = 0;

		// 扑克分析
		for (int i = 0; i < cbHandCardCount; i++) {
			// 变量定义
			int cbSameCount = 1;
			int cbLogicValue = GetCardLogicValue(cbTmpCardData[i]);

			// 搜索同牌
			for (int j = i + 1; j < cbHandCardCount; j++) {
				// 获取扑克
				if (GetCardLogicValue(cbTmpCardData[j]) != cbLogicValue)
					break;

				// 设置变量
				cbSameCount++;
			}

			if (cbSameCount >= 3) {
				cbThreeCardData[cbThreeCardCount++] = cbTmpCardData[i];
				cbThreeCardData[cbThreeCardCount++] = cbTmpCardData[i + 1];
				cbThreeCardData[cbThreeCardCount++] = cbTmpCardData[i + 2];
			}

			// 设置索引
			i += cbSameCount - 1;
		}
		return cbThreeCardCount;
	}

	// 分析对子
	int GetAllDoubleCard(int cbHandCardData[], int cbHandCardCount, int cbDoubleCardData[], int cbDoubleCardCount) {
		int cbTmpCardData[] = new int[Constants.MAX_COUNT];
		Constants.CopyMemory(cbTmpCardData, cbHandCardData, cbHandCardCount);

		// 大小排序
		SortCardList(cbTmpCardData, cbHandCardCount, Constants.ST_ORDER);

		cbDoubleCardCount = 0;

		// 扑克分析
		for (int i = 0; i < cbHandCardCount; i++) {
			// 变量定义
			int cbSameCount = 1;
			int cbLogicValue = GetCardLogicValue(cbTmpCardData[i]);

			// 搜索同牌
			for (int j = i + 1; j < cbHandCardCount; j++) {
				// 获取扑克
				if (GetCardLogicValue(cbTmpCardData[j]) != cbLogicValue)
					break;

				// 设置变量
				cbSameCount++;
			}

			if (cbSameCount >= 2) {
				cbDoubleCardData[cbDoubleCardCount++] = cbTmpCardData[i];
				cbDoubleCardData[cbDoubleCardCount++] = cbTmpCardData[i + 1];
			}

			// 设置索引
			i += cbSameCount - 1;
		}
		return cbDoubleCardCount;
	}

	// 分析单牌
	int GetAllSingleCard(int cbHandCardData[], int cbHandCardCount, int cbSingleCardData[], int cbSingleCardCount) {
		cbSingleCardCount = 0;

		int cbTmpCardData[] = new int[Constants.MAX_COUNT];
		Constants.CopyMemory(cbTmpCardData, cbHandCardData, cbHandCardCount);

		// 大小排序
		SortCardList(cbTmpCardData, cbHandCardCount, Constants.ST_ORDER);

		// 扑克分析
		for (int i = 0; i < cbHandCardCount; i++) {
			// 变量定义
			int cbSameCount = 1;
			int cbLogicValue = GetCardLogicValue(cbTmpCardData[i]);

			// 搜索同牌
			for (int j = i + 1; j < cbHandCardCount; j++) {
				// 获取扑克
				if (GetCardLogicValue(cbTmpCardData[j]) != cbLogicValue)
					break;

				// 设置变量
				cbSameCount++;
			}

			if (cbSameCount == 1) {
				cbSingleCardData[cbSingleCardCount++] = cbTmpCardData[i];
			}

			// 设置索引
			i += cbSameCount - 1;
		}
		return cbSingleCardCount;
	}

	private void AnalyseOutCardType(int[] cbHandCardData, int cbHandCardCount, tagOutCardTypeResult_Server[] CardTypeResult) {
		

		int cbTmpCardData[] = new int[Constants.MAX_COUNT];
		// 保留扑克，防止分析时改变扑克
		int cbReserveCardData[] = new int[Constants.MAX_COUNT];
		Constants.CopyMemory(cbReserveCardData, cbHandCardData, cbHandCardCount);
		SortCardList(cbReserveCardData, cbHandCardCount, Constants.ST_ORDER);
		Constants.CopyMemory(cbTmpCardData, cbReserveCardData, cbHandCardCount);

		// 单牌类型
		for (int i = 0; i < cbHandCardCount; ++i) {
			int Index = CardTypeResult[Constants.CT_SINGLE].cbCardTypeCount;
			CardTypeResult[Constants.CT_SINGLE].cbCardType = Constants.CT_SINGLE;
			CardTypeResult[Constants.CT_SINGLE].cbCardData[Index][0] = cbTmpCardData[i];
			CardTypeResult[Constants.CT_SINGLE].cbEachHandCardCount[Index] = 1;
			CardTypeResult[Constants.CT_SINGLE].cbCardTypeCount++;

			// ASSERT(CardTypeResult[Constants.CT_SINGLE].cbCardTypeCount<Constants.MAX_TYPE_COUNT)
			// ;
		}

		// 对牌类型
		{
			int cbDoubleCardData[] = new int[Constants.MAX_COUNT];
			int cbDoubleCardcount = 0;
			cbDoubleCardcount = GetAllDoubleCard(cbTmpCardData, cbHandCardCount, cbDoubleCardData, cbDoubleCardcount);
			for (int i = 0; i < cbDoubleCardcount; i += 2) {
				int Index = CardTypeResult[Constants.CT_DOUBLE].cbCardTypeCount;
				CardTypeResult[Constants.CT_DOUBLE].cbCardType = Constants.CT_DOUBLE;
				CardTypeResult[Constants.CT_DOUBLE].cbCardData[Index][0] = cbDoubleCardData[i];
				CardTypeResult[Constants.CT_DOUBLE].cbCardData[Index][1] = cbDoubleCardData[i + 1];
				CardTypeResult[Constants.CT_DOUBLE].cbEachHandCardCount[Index] = 2;
				CardTypeResult[Constants.CT_DOUBLE].cbCardTypeCount++;

				// ASSERT(CardTypeResult[Constants.CT_DOUBLE].cbCardTypeCount<Constants.MAX_TYPE_COUNT)
				// ;
			}
		}

		// 三条类型
		{
			int cbThreeCardData[] = new int[Constants.MAX_COUNT];
			int cbThreeCardCount = 0;
			cbThreeCardCount = GetAllThreeCard(cbTmpCardData, cbHandCardCount, cbThreeCardData, cbThreeCardCount);
			for (int i = 0; i < cbThreeCardCount; i += 3) {
				int Index = CardTypeResult[Constants.CT_THREE].cbCardTypeCount;
				CardTypeResult[Constants.CT_THREE].cbCardType = Constants.CT_THREE;
				CardTypeResult[Constants.CT_THREE].cbCardData[Index][0] = cbThreeCardData[i];
				CardTypeResult[Constants.CT_THREE].cbCardData[Index][1] = cbThreeCardData[i + 1];
				CardTypeResult[Constants.CT_THREE].cbCardData[Index][2] = cbThreeCardData[i + 2];
				CardTypeResult[Constants.CT_THREE].cbEachHandCardCount[Index] = 3;
				CardTypeResult[Constants.CT_THREE].cbCardTypeCount++;

				// ASSERT(CardTypeResult[Constants.CT_THREE].cbCardTypeCount<Constants.MAX_TYPE_COUNT)
				// ;
			}
		}

		// 炸弹类型
		{
			int cbFourCardData[] = new int[Constants.MAX_COUNT];
			int cbFourCardCount = 0;
			if (cbHandCardCount >= 2 && 0x4F == cbTmpCardData[0] && 0x4E == cbTmpCardData[1]) {
				int Index = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardType = Constants.CT_BOMB_CARD;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index][0] = cbTmpCardData[0];
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index][1] = cbTmpCardData[1];
				CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[Index] = 2;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount++;
				cbFourCardCount = GetAllBomCard(cbTmpCardData, 2, cbHandCardCount - 2, cbFourCardData, cbFourCardCount);
			} else
				cbFourCardCount = GetAllBomCard(cbTmpCardData, cbHandCardCount, cbFourCardData, cbFourCardCount);
			for (int i = 0; i < cbFourCardCount; i += 4) {
				int Index = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardType = Constants.CT_BOMB_CARD;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index][0] = cbFourCardData[i];
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index][1] = cbFourCardData[i + 1];
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index][2] = cbFourCardData[i + 2];
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index][3] = cbFourCardData[i + 3];
				CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[Index] = 4;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount++;

				// ASSERT(CardTypeResult[CT_BOMB_CARD].cbCardTypeCount<MAX_TYPE_COUNT)
				// ;
			}
		}
		// 单连类型
		{
			// 恢复扑克，防止分析时改变扑克
			Constants.CopyMemory(cbTmpCardData, cbReserveCardData, cbHandCardCount);

			int cbFirstCard = 0;
			// 去除2和王
			for (int i = 0; i < cbHandCardCount; ++i) {
				if (GetCardLogicValue(cbTmpCardData[i]) < 15) {
					cbFirstCard = i;
					break;
				}
			}

			int cbSingleLineCard[] = new int[12];
			int cbSingleLineCount = 1;
			int cbLeftCardCount = cbHandCardCount;
			boolean bFindSingleLine = true;

			// 连牌判断
			while (cbLeftCardCount >= 5 && bFindSingleLine) {
				cbSingleLineCount = 1;
				bFindSingleLine = false;
				int cbLastCard = cbTmpCardData[cbFirstCard];
				cbSingleLineCard[cbSingleLineCount - 1] = cbTmpCardData[cbFirstCard];
				for (int i = cbFirstCard + 1; i < cbLeftCardCount; i++) {
					int cbCardData = cbTmpCardData[i];

					// 连续判断
					if (1 != (GetCardLogicValue(cbLastCard) - GetCardLogicValue(cbCardData))
							&& GetCardValue(cbLastCard) != GetCardValue(cbCardData)) {
						cbLastCard = cbTmpCardData[i];
						// 是否合法
						if (cbSingleLineCount < 5) {
							cbSingleLineCount = 1;
							cbSingleLineCard[cbSingleLineCount - 1] = cbTmpCardData[i];
							continue;
						} else
							break;
					}
					// 同牌判断
					else if (GetCardValue(cbLastCard) != GetCardValue(cbCardData)) {
						cbLastCard = cbCardData;
						cbSingleLineCard[cbSingleLineCount] = cbCardData;
						++cbSingleLineCount;
					}
				}

				// 保存数据
				if (cbSingleLineCount >= 5) {
					int Index;
					// 所有连牌

					int nStart = 0;

					// 从大到小
					nStart = cbSingleLineCount - 5;
					while (0 < nStart) {
						Index = CardTypeResult[Constants.CT_SINGLE_LINE].cbCardTypeCount;
						int cbThisLineCount = cbSingleLineCount - nStart;
						CardTypeResult[Constants.CT_SINGLE_LINE].cbCardType = Constants.CT_SINGLE_LINE;
						Constants.CopyMemory(CardTypeResult[Constants.CT_SINGLE_LINE].cbCardData[Index],
								cbSingleLineCard, (cbThisLineCount));
						CardTypeResult[Constants.CT_SINGLE_LINE].cbEachHandCardCount[Index] = cbThisLineCount;
						CardTypeResult[Constants.CT_SINGLE_LINE].cbCardTypeCount++;

						// ASSERT(CardTypeResult[Constants.CT_SINGLE_LINE].cbCardTypeCount<Constants.MAX_TYPE_COUNT)
						// ;
						nStart--;
					}

					// 从小到大
					nStart = cbSingleLineCount - 5;
					while (0 <= nStart) {
						Index = CardTypeResult[Constants.CT_SINGLE_LINE].cbCardTypeCount;
						int cbThisLineCount = cbSingleLineCount - nStart;
						CardTypeResult[Constants.CT_SINGLE_LINE].cbCardType = Constants.CT_SINGLE_LINE;
						Constants.CopyMemory(CardTypeResult[Constants.CT_SINGLE_LINE].cbCardData[Index], 0,
								cbSingleLineCard, nStart, (cbThisLineCount));
						CardTypeResult[Constants.CT_SINGLE_LINE].cbEachHandCardCount[Index] = cbThisLineCount;
						CardTypeResult[Constants.CT_SINGLE_LINE].cbCardTypeCount++;

						// ASSERT(CardTypeResult[Constants.CT_SINGLE_LINE].cbCardTypeCount<Constants.MAX_TYPE_COUNT)
						// ;
						nStart--;
					}

					RemoveCard(cbSingleLineCard, cbSingleLineCount, cbTmpCardData, cbLeftCardCount);
					cbLeftCardCount -= cbSingleLineCount;
					bFindSingleLine = true;
				}
			}

		}

		// 对连类型
		{
			// 恢复扑克，防止分析时改变扑克
			Constants.CopyMemory(cbTmpCardData, cbReserveCardData, cbHandCardCount);

			// 连牌判断
			int cbFirstCard = 0;
			// 去除2和王
			for (int i = 0; i < cbHandCardCount; ++i)
				if (GetCardLogicValue(cbTmpCardData[i]) < 15) {
					cbFirstCard = i;
					break;
				}

			int cbLeftCardCount = cbHandCardCount - cbFirstCard;
			boolean bFindDoubleLine = true;
			int cbDoubleLineCount = 0;
			int cbDoubleLineCard[] = new int[24];
			// 开始判断
			while (cbLeftCardCount >= 6 && bFindDoubleLine) {
				int cbLastCard = cbTmpCardData[cbFirstCard];
				int cbSameCount = 1;
				cbDoubleLineCount = 0;
				bFindDoubleLine = false;
				for (int i = cbFirstCard + 1; i < cbLeftCardCount + cbFirstCard; ++i) {
					// 搜索同牌
					try {
						while ( i < cbLeftCardCount + cbFirstCard && GetCardLogicValue(cbLastCard) == GetCardLogicValue(cbTmpCardData[i]) ) {
							++cbSameCount;
							++i;
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
					

					int cbLastDoubleCardValue = 0;
					if (cbDoubleLineCount > 0)
						cbLastDoubleCardValue = GetCardLogicValue(cbDoubleLineCard[cbDoubleLineCount - 1]);
					// 重新开始
					if ((cbSameCount < 2
							|| (cbDoubleLineCount > 0 && (cbLastDoubleCardValue - GetCardLogicValue(cbLastCard)) != 1))
							&& i <= cbLeftCardCount + cbFirstCard) {
						if (cbDoubleLineCount >= 6)
							break;
						// 回退
						if (cbSameCount >= 2)
							i -= cbSameCount;
						cbLastCard = cbTmpCardData[i];
						cbDoubleLineCount = 0;
					}
					// 保存数据
					else if (cbSameCount >= 2) {
						cbDoubleLineCard[cbDoubleLineCount] = cbTmpCardData[i - cbSameCount];
						cbDoubleLineCard[cbDoubleLineCount + 1] = cbTmpCardData[i - cbSameCount + 1];
						cbDoubleLineCount += 2;

						// 结尾判断
						if (i == (cbLeftCardCount + cbFirstCard - 2))
							if ((GetCardLogicValue(cbLastCard) - GetCardLogicValue(cbTmpCardData[i])) == 1
									&& (GetCardLogicValue(cbTmpCardData[i]) == GetCardLogicValue(
											cbTmpCardData[i + 1]))) {
								cbDoubleLineCard[cbDoubleLineCount] = cbTmpCardData[i];
								cbDoubleLineCard[cbDoubleLineCount + 1] = cbTmpCardData[i + 1];
								cbDoubleLineCount += 2;
								break;
							}

					}
					if (i < cbTmpCardData.length) {
						cbLastCard = cbTmpCardData[i];
					}else{
						cbLastCard = cbTmpCardData[cbTmpCardData.length - 1];
					}
					cbSameCount = 1;
				}

				// 保存数据
				if (cbDoubleLineCount >= 6) {
					int Index;

					// 所有连牌
					int cbCurrentDoubleLineCount = 6;
					while (cbCurrentDoubleLineCount < cbDoubleLineCount) {
						Index = CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardTypeCount;
						CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardType = Constants.CT_DOUBLE_LINE;
						Constants.CopyMemory(CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardData[Index],
								cbDoubleLineCard, cbCurrentDoubleLineCount);
						CardTypeResult[Constants.CT_DOUBLE_LINE].cbEachHandCardCount[Index] = cbCurrentDoubleLineCount;
						CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardTypeCount++;

						cbCurrentDoubleLineCount += 2;

						// ASSERT(CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardTypeCount<Constants.MAX_TYPE_COUNT)
						// ;
					}

					// 从小到大
					if (cbDoubleLineCount >= 6) {
						// 所有连牌
						int cbLeftLen = cbDoubleLineCount - 6;
						while (cbLeftLen >= 0) {
							Index = CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardTypeCount;
							CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardType = Constants.CT_DOUBLE_LINE;
							Constants.CopyMemory(CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardData[Index], 0,
									cbDoubleLineCard, cbLeftLen, (cbDoubleLineCount - cbLeftLen));
							CardTypeResult[Constants.CT_DOUBLE_LINE].cbEachHandCardCount[Index] = cbDoubleLineCount
									- cbLeftLen;
							CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardTypeCount++;

							cbLeftLen -= 2;

							// ASSERT(CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardTypeCount<Constants.MAX_TYPE_COUNT)
							// ;
						}
					}

					RemoveCard(cbDoubleLineCard, cbDoubleLineCount, cbTmpCardData, cbFirstCard + cbLeftCardCount);
					bFindDoubleLine = true;
					cbLeftCardCount -= cbDoubleLineCount;
				}
			}
		}

		// 三连类型
		{
			// 恢复扑克，防止分析时改变扑克
			Constants.CopyMemory(cbTmpCardData, cbReserveCardData, cbHandCardCount);

			// 连牌判断
			int cbFirstCard = 0;
			// 去除2和王
			for (int i = 0; i < cbHandCardCount; ++i)
				if (GetCardLogicValue(cbTmpCardData[i]) < 15) {
					cbFirstCard = i;
					break;
				}

			int cbLeftCardCount = cbHandCardCount - cbFirstCard;
			boolean bFindThreeLine = true;
			int cbThreeLineCount = 0;
			int cbThreeLineCard[] = new int[20];
			// 开始判断
			while (cbLeftCardCount >= 6 && bFindThreeLine) {
				int cbLastCard = cbTmpCardData[cbFirstCard];
				int cbSameCount = 1;
				cbThreeLineCount = 0;
				bFindThreeLine = false;
				for (int i = cbFirstCard + 1; i < cbLeftCardCount + cbFirstCard; ++i) {
					// 搜索同牌
					while (i < cbLeftCardCount + cbFirstCard && GetCardLogicValue(cbLastCard) == GetCardLogicValue(cbTmpCardData[i])
							 ) {
						++cbSameCount;
						++i;
					}

					int cbLastThreeCardValue = 0;
					if (cbThreeLineCount > 0)
						cbLastThreeCardValue = GetCardLogicValue(cbThreeLineCard[cbThreeLineCount - 1]);

					// 重新开始
					if ((cbSameCount < 3
							|| (cbThreeLineCount > 0 && (cbLastThreeCardValue - GetCardLogicValue(cbLastCard)) != 1))
							&& i <= cbLeftCardCount + cbFirstCard) {
						if (cbThreeLineCount >= 6)
							break;

						if (cbSameCount >= 3)
							i -= cbSameCount;
						cbLastCard = cbTmpCardData[i];
						cbThreeLineCount = 0;
					}
					// 保存数据
					else if (cbSameCount >= 3) {
						cbThreeLineCard[cbThreeLineCount] = cbTmpCardData[i - cbSameCount];
						cbThreeLineCard[cbThreeLineCount + 1] = cbTmpCardData[i - cbSameCount + 1];
						cbThreeLineCard[cbThreeLineCount + 2] = cbTmpCardData[i - cbSameCount + 2];
						cbThreeLineCount += 3;

						// 结尾判断
						if (i == (cbLeftCardCount + cbFirstCard - 3))
							if ((GetCardLogicValue(cbLastCard) - GetCardLogicValue(cbTmpCardData[i])) == 1
									&& (GetCardLogicValue(cbTmpCardData[i]) == GetCardLogicValue(cbTmpCardData[i + 1]))
									&& (GetCardLogicValue(cbTmpCardData[i]) == GetCardLogicValue(
											cbTmpCardData[i + 2]))) {
								cbThreeLineCard[cbThreeLineCount] = cbTmpCardData[i];
								cbThreeLineCard[cbThreeLineCount + 1] = cbTmpCardData[i + 1];
								cbThreeLineCard[cbThreeLineCount + 2] = cbTmpCardData[i + 2];
								cbThreeLineCount += 3;
								break;
							}

					}
					if (i < cbTmpCardData.length) {
						cbLastCard = cbTmpCardData[i];
					}else{
						cbLastCard = cbTmpCardData[cbTmpCardData.length - 1];
					}
					
					cbSameCount = 1;
				}

				// 保存数据
				if (cbThreeLineCount >= 6) {
					int Index;

					Index = CardTypeResult[Constants.CT_THREE_LINE].cbCardTypeCount;
					CardTypeResult[Constants.CT_THREE_LINE].cbCardType = Constants.CT_THREE_LINE;
					Constants.CopyMemory(CardTypeResult[Constants.CT_THREE_LINE].cbCardData[Index], cbThreeLineCard,
							cbThreeLineCount);
					CardTypeResult[Constants.CT_THREE_LINE].cbEachHandCardCount[Index] = cbThreeLineCount;
					CardTypeResult[Constants.CT_THREE_LINE].cbCardTypeCount++;

					// ASSERT(CardTypeResult[Constants.CT_THREE_LINE].cbCardTypeCount<Constants.MAX_TYPE_COUNT)
					// ;

					RemoveCard(cbThreeLineCard, cbThreeLineCount, cbTmpCardData, cbFirstCard + cbLeftCardCount);
					bFindThreeLine = true;
					cbLeftCardCount -= cbThreeLineCount;
				}
			}

		}
		// 三带一单
		{
			// 恢复扑克，防止分析时改变扑克
			Constants.CopyMemory(cbTmpCardData, cbReserveCardData, cbHandCardCount);

			int cbHandThreeCard[] = new int[Constants.MAX_COUNT];
			int cbHandThreeCount = 0;

			// 移除炸弹
			int cbAllBomCardData[] = new int[Constants.MAX_COUNT];
			int cbAllBomCardCount = 0;
			cbAllBomCardCount = GetAllBomCard(cbTmpCardData, cbHandCardCount, cbAllBomCardData, cbAllBomCardCount);
			RemoveCard(cbAllBomCardData, cbAllBomCardCount, cbTmpCardData, cbHandCardCount);

			cbHandThreeCount = GetAllThreeCard(cbTmpCardData, cbHandCardCount - cbAllBomCardCount, cbHandThreeCard,
					cbHandThreeCount);

			{
				int Index;
				// 去掉三条
				int cbRemainCardData[] = new int[Constants.MAX_COUNT];
				Constants.CopyMemory(cbRemainCardData, cbTmpCardData, cbHandCardCount - cbAllBomCardCount);
				int cbRemainCardCount = cbHandCardCount - cbAllBomCardCount - cbHandThreeCount;
				RemoveCard(cbHandThreeCard, cbHandThreeCount, cbRemainCardData, cbHandCardCount - cbAllBomCardCount);
				// 三条带一张
				for (int i = 0; i < cbHandThreeCount; i += 3) {
					// 三条带一张
					for (int j = 0; j < cbRemainCardCount; ++j) {
						Index = CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardTypeCount;
						CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardType = Constants.CT_THREE_LINE_TAKE_ONE;
						CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardData[Index][0] = cbHandThreeCard[i];
						CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardData[Index][1] = cbHandThreeCard[i + 1];
						CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardData[Index][2] = cbHandThreeCard[i + 2];
						CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardData[Index][3] = cbRemainCardData[j];
						CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbEachHandCardCount[Index] = 4;
						CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardTypeCount++;
					}
				}
			}

			// 三连带单
			int cbLeftThreeCardCount = cbHandThreeCount;
			boolean bFindThreeLine = true;
			int cbLastIndex = 0;
			if (GetCardLogicValue(cbHandThreeCard[0]) == 15)
				cbLastIndex = 3;
			while (cbLeftThreeCardCount >= 6 && bFindThreeLine) {
				int cbLastLogicCard = GetCardLogicValue(cbHandThreeCard[cbLastIndex]);
				int cbThreeLineCard[] = new int[Constants.MAX_COUNT];
				int cbThreeLineCardCount = 3;
				cbThreeLineCard[0] = cbHandThreeCard[cbLastIndex];
				cbThreeLineCard[1] = cbHandThreeCard[cbLastIndex + 1];
				cbThreeLineCard[2] = cbHandThreeCard[cbLastIndex + 2];

				bFindThreeLine = false;
				for (int j = 3 + cbLastIndex; j < cbLeftThreeCardCount; j += 3) {
					// 连续判断
					if (1 != (cbLastLogicCard - (GetCardLogicValue(cbHandThreeCard[j])))) {
						cbLastIndex = j;
						if (cbLeftThreeCardCount - j >= 6)
							bFindThreeLine = true;

						break;
					}

					cbLastLogicCard = GetCardLogicValue(cbHandThreeCard[j]);
					cbThreeLineCard[cbThreeLineCardCount] = cbHandThreeCard[j];
					cbThreeLineCard[cbThreeLineCardCount + 1] = cbHandThreeCard[j + 1];
					cbThreeLineCard[cbThreeLineCardCount + 2] = cbHandThreeCard[j + 2];
					cbThreeLineCardCount += 3;
				}
				if (cbThreeLineCardCount > 3) {
					int Index;

					int cbRemainCard[] = new int[Constants.MAX_COUNT];
					int cbRemainCardCount = cbHandCardCount - cbAllBomCardCount - cbHandThreeCount;

					// 移除三条（还应该移除炸弹王等）
					Constants.CopyMemory(cbRemainCard, cbTmpCardData, (cbHandCardCount - cbAllBomCardCount));
					RemoveCard(cbHandThreeCard, cbHandThreeCount, cbRemainCard, cbHandCardCount - cbAllBomCardCount);

					for (int start = 0; start < cbThreeLineCardCount - 3; start += 3) {
						// 本顺数目
						int cbThisTreeLineCardCount = cbThreeLineCardCount - start;
						// 单牌个数
						int cbSingleCardCount = (cbThisTreeLineCardCount) / 3;

						// 单牌不够
						if (cbRemainCardCount < cbSingleCardCount)
							continue;

						// 单牌组合
						int cbComCard[] = new int[5];
						int cbComResCard[][] = new int[254][5];
						int cbComResLen = 0;

						cbComResLen = Combination(cbComCard, 0, cbComResCard, cbComResLen, cbRemainCard, cbSingleCardCount,
								cbRemainCardCount, cbSingleCardCount);
						for (int i = 0; i < cbComResLen; ++i) {
							Index = CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardTypeCount;
							CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardType = Constants.CT_THREE_LINE_TAKE_ONE;
							// 保存三条
							Constants.CopyMemory(CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardData[Index], 0,
									cbThreeLineCard, start, cbThisTreeLineCardCount);
							// 保存单牌
							Constants.CopyMemory(CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardData[Index],
									cbThisTreeLineCardCount, cbComResCard[i], cbSingleCardCount);

							CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbEachHandCardCount[Index] = cbThisTreeLineCardCount
									+ cbSingleCardCount;
							CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardTypeCount++;

							// ASSERT(CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardTypeCount<Constants.MAX_TYPE_COUNT)
							// ;
						}

					}

					// 移除三连
					bFindThreeLine = true;
					RemoveCard(cbThreeLineCard, cbThreeLineCardCount, cbHandThreeCard, cbLeftThreeCardCount);
					cbLeftThreeCardCount -= cbThreeLineCardCount;
				}
			}
		}

		// 三带一对
		{
			// 恢复扑克，防止分析时改变扑克
			Constants.CopyMemory(cbTmpCardData, cbReserveCardData, cbHandCardCount);

			int cbHandThreeCard[] = new int[Constants.MAX_COUNT];
			int cbHandThreeCount = 0;
			int cbRemainCarData[] = new int[Constants.MAX_COUNT];
			int cbRemainCardCount = 0;

			// 抽取三条
			cbHandThreeCount = GetAllThreeCard(cbTmpCardData, cbHandCardCount, cbHandThreeCard, cbHandThreeCount);

			// 移除三条（还应该移除炸弹王等）
			Constants.CopyMemory(cbRemainCarData, cbTmpCardData, cbHandCardCount);
			RemoveCard(cbHandThreeCard, cbHandThreeCount, cbRemainCarData, cbHandCardCount);
			cbRemainCardCount = cbHandCardCount - cbHandThreeCount;

			// 抽取对牌
			int cbAllDoubleCardData[] = new int[Constants.MAX_COUNT];
			int cbAllDoubleCardCount = 0;
			cbAllDoubleCardCount = GetAllDoubleCard(cbRemainCarData, cbRemainCardCount, cbAllDoubleCardData, cbAllDoubleCardCount);

			// 三条带一对
			for (int i = 0; i < cbHandThreeCount; i += 3) {
				int Index;

				// 三条带一张
				for (int j = 0; j < cbAllDoubleCardCount; j += 2) {
					Index = CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardTypeCount;
					CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardType = Constants.CT_THREE_LINE_TAKE_TWO;
					CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardData[Index][0] = cbHandThreeCard[i];
					CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardData[Index][1] = cbHandThreeCard[i + 1];
					CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardData[Index][2] = cbHandThreeCard[i + 2];
					CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardData[Index][3] = cbAllDoubleCardData[j];
					CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardData[Index][4] = cbAllDoubleCardData[j + 1];
					CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbEachHandCardCount[Index] = 5;
					CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardTypeCount++;
				}
			}

			// 三连带对
			int cbLeftThreeCardCount = cbHandThreeCount;
			boolean bFindThreeLine = true;
			int cbLastIndex = 0;
			if (GetCardLogicValue(cbHandThreeCard[0]) == 15)
				cbLastIndex = 3;
			while (cbLeftThreeCardCount >= 6 && bFindThreeLine) {
				int cbLastLogicCard = GetCardLogicValue(cbHandThreeCard[cbLastIndex]);
				int cbThreeLineCard[] = new int[Constants.MAX_COUNT];
				int cbThreeLineCardCount = 3;
				cbThreeLineCard[0] = cbHandThreeCard[cbLastIndex];
				cbThreeLineCard[1] = cbHandThreeCard[cbLastIndex + 1];
				cbThreeLineCard[2] = cbHandThreeCard[cbLastIndex + 2];

				bFindThreeLine = false;
				for (int j = 3 + cbLastIndex; j < cbLeftThreeCardCount; j += 3) {
					// 连续判断
					if (1 != (cbLastLogicCard - (GetCardLogicValue(cbHandThreeCard[j])))) {
						cbLastIndex = j;
						if (cbLeftThreeCardCount - j >= 6)
							bFindThreeLine = true;

						break;
					}

					cbLastLogicCard = GetCardLogicValue(cbHandThreeCard[j]);
					cbThreeLineCard[cbThreeLineCardCount] = cbHandThreeCard[j];
					cbThreeLineCard[cbThreeLineCardCount + 1] = cbHandThreeCard[j + 1];
					cbThreeLineCard[cbThreeLineCardCount + 2] = cbHandThreeCard[j + 2];
					cbThreeLineCardCount += 3;
				}
				if (cbThreeLineCardCount > 3) {
					int Index;

					for (int start = 0; start < cbThreeLineCardCount - 3; start += 3) {
						// 本顺数目
						int cbThisTreeLineCardCount = cbThreeLineCardCount - start;
						// 对牌张数
						int cbDoubleCardCount = ((cbThisTreeLineCardCount) / 3);

						// 对牌不够
						if (cbRemainCardCount < cbDoubleCardCount)
							continue;

						int cbDoubleCardIndex[] = new int[10]; // 对牌下标
						for (int i = 0, j = 0; i < cbAllDoubleCardCount; i += 2, ++j)
							cbDoubleCardIndex[j] = i;

						// 对牌组合
						int cbComCard[] = new int[5];
						int cbComResCard[][] = new int[254][5];
						int cbComResLen = 0;

						// 利用对牌的下标做组合，再根据下标提取出对牌
						Combination(cbComCard, 0, cbComResCard, cbComResLen, cbDoubleCardIndex, cbDoubleCardCount,
								cbAllDoubleCardCount / 2, cbDoubleCardCount);

						// ASSERT(cbComResLen<=254) ;

						for (int i = 0; i < cbComResLen; ++i) {
							Index = CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardTypeCount;
							CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardType = Constants.CT_THREE_LINE_TAKE_TWO;
							// 保存三条
							Constants.CopyMemory(CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardData[Index], 0,
									cbThreeLineCard, start, cbThisTreeLineCardCount);
							// 保存对牌
							for (int j = 0, k = 0; j < cbDoubleCardCount; ++j, k += 2) {
								CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardData[Index][cbThisTreeLineCardCount
										+ k] = cbAllDoubleCardData[cbComResCard[i][j]];
								CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardData[Index][cbThisTreeLineCardCount
										+ k + 1] = cbAllDoubleCardData[cbComResCard[i][j] + 1];
							}

							CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbEachHandCardCount[Index] = cbThisTreeLineCardCount
									+ 2 * cbDoubleCardCount;
							CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardTypeCount++;

							// ASSERT(CardTypeResult[CT_THREE_LINE_TAKE_TWO].cbCardTypeCount<MAX_TYPE_COUNT)
							// ;
						}

					}
					// 移除三连
					bFindThreeLine = true;
					RemoveCard(cbThreeLineCard, cbThreeLineCardCount, cbHandThreeCard, cbLeftThreeCardCount);
					cbLeftThreeCardCount -= cbThreeLineCardCount;
				}
			}
		}
		// 四带两单
		/*
		 * { //恢复扑克，防止分析时改变扑克 CopyMemory(cbTmpCardData, cbReserveCardData,
		 * cbHandCardCount) ;
		 * 
		 * int cbFirstCard = 0 ; //去除王牌 for(int i=0 ; i<cbHandCardCount ; ++i)
		 * if(GetCardColor(cbTmpCardData[i])!=0x40) {cbFirstCard = i ; break ;}
		 * 
		 * int cbHandAllFourCardData[MAX_COUNT] ; int cbHandAllFourCardCount=0;
		 * //抽取四张 GetAllBomCard(cbTmpCardData+cbFirstCard,
		 * cbHandCardCount-cbFirstCard, cbHandAllFourCardData,
		 * cbHandAllFourCardCount) ;
		 * 
		 * //移除四条 int cbRemainCard[MAX_COUNT]; int
		 * cbRemainCardCount=cbHandCardCount-cbHandAllFourCardCount ;
		 * CopyMemory(cbRemainCard, cbTmpCardData, cbHandCardCount*sizeof(int));
		 * RemoveCard(cbHandAllFourCardData, cbHandAllFourCardCount,
		 * cbRemainCard, cbHandCardCount) ;
		 * 
		 * for(int Start=0; Start<cbHandAllFourCardCount; Start += 4) { int
		 * Index ; //单牌组合 int cbComCard[5]; int cbComResCard[254][5] ; int
		 * cbComResLen=0 ; //单牌组合 Combination(cbComCard, 0, cbComResCard,
		 * cbComResLen, cbRemainCard, 2, cbRemainCardCount, 2); for(int i=0;
		 * i<cbComResLen; ++i) { //不能带对
		 * if(GetCardValue(cbComResCard[i][0])==GetCardValue(cbComResCard[i][1])
		 * ) continue ;
		 * 
		 * Index=CardTypeResult[CT_FOUR_LINE_TAKE_ONE].cbCardTypeCount ;
		 * CardTypeResult[CT_FOUR_LINE_TAKE_ONE].cbCardType =
		 * CT_FOUR_LINE_TAKE_ONE ;
		 * CopyMemory(CardTypeResult[CT_FOUR_LINE_TAKE_ONE].cbCardData[Index],
		 * cbHandAllFourCardData+Start, 4) ;
		 * CardTypeResult[CT_FOUR_LINE_TAKE_ONE].cbCardData[Index][4] =
		 * cbComResCard[i][0] ;
		 * CardTypeResult[CT_FOUR_LINE_TAKE_ONE].cbCardData[Index][4+1] =
		 * cbComResCard[i][1] ;
		 * CardTypeResult[CT_FOUR_LINE_TAKE_ONE].cbEachHandCardCount[Index] = 6
		 * ; CardTypeResult[CT_FOUR_LINE_TAKE_ONE].cbCardTypeCount++ ;
		 * 
		 * ASSERT(CardTypeResult[CT_FOUR_LINE_TAKE_ONE].cbCardTypeCount<
		 * MAX_TYPE_COUNT) ; } } }
		 */

		// 四带两对
		/*
		 * { //恢复扑克，防止分析时改变扑克 CopyMemory(cbTmpCardData, cbReserveCardData,
		 * cbHandCardCount) ;
		 * 
		 * int cbFirstCard = 0 ; //去除王牌 for(int i=0 ; i<cbHandCardCount ; ++i)
		 * if(GetCardColor(cbTmpCardData[i])!=0x40) {cbFirstCard = i ; break ;}
		 * 
		 * int cbHandAllFourCardData[MAX_COUNT] ; int cbHandAllFourCardCount=0;
		 * 
		 * //抽取四张 GetAllBomCard(cbTmpCardData+cbFirstCard,
		 * cbHandCardCount-cbFirstCard, cbHandAllFourCardData,
		 * cbHandAllFourCardCount) ;
		 * 
		 * //移除四条 int cbRemainCard[MAX_COUNT]; int
		 * cbRemainCardCount=cbHandCardCount-cbHandAllFourCardCount ;
		 * CopyMemory(cbRemainCard, cbTmpCardData, cbHandCardCount*sizeof(int));
		 * RemoveCard(cbHandAllFourCardData, cbHandAllFourCardCount,
		 * cbRemainCard, cbHandCardCount) ;
		 * 
		 * for(int Start=0; Start<cbHandAllFourCardCount; Start += 4) { //抽取对牌
		 * int cbAllDoubleCardData[MAX_COUNT] ; int cbAllDoubleCardCount=0 ;
		 * GetAllDoubleCard(cbRemainCard, cbRemainCardCount,
		 * cbAllDoubleCardData, cbAllDoubleCardCount) ;
		 * 
		 * int cbDoubleCardIndex[10]; //对牌下标 for(int i=0, j=0;
		 * i<cbAllDoubleCardCount; i+=2, ++j) cbDoubleCardIndex[j]=i ;
		 * 
		 * //对牌组合 int cbComCard[5]; int cbComResCard[255][5] ; int cbComResLen=0
		 * ;
		 * 
		 * //利用对牌的下标做组合，再根据下标提取出对牌 Combination(cbComCard, 0, cbComResCard,
		 * cbComResLen, cbDoubleCardIndex, 2, cbAllDoubleCardCount/2, 2);
		 * for(int i=0; i<cbComResLen; ++i) { int Index =
		 * CardTypeResult[CT_FOUR_LINE_TAKE_TWO].cbCardTypeCount ;
		 * CardTypeResult[CT_FOUR_LINE_TAKE_TWO].cbCardType =
		 * CT_FOUR_LINE_TAKE_TWO ;
		 * CopyMemory(CardTypeResult[CT_FOUR_LINE_TAKE_TWO].cbCardData[Index],
		 * cbHandAllFourCardData+Start, 4) ;
		 * 
		 * //保存对牌 for(int j=0, k=0; j<4; ++j, k+=2) {
		 * CardTypeResult[CT_FOUR_LINE_TAKE_TWO].cbCardData[Index][4+k] =
		 * cbAllDoubleCardData[cbComResCard[i][j]];
		 * CardTypeResult[CT_FOUR_LINE_TAKE_TWO].cbCardData[Index][4+k+1] =
		 * cbAllDoubleCardData[cbComResCard[i][j]+1]; }
		 * 
		 * CardTypeResult[CT_FOUR_LINE_TAKE_TWO].cbEachHandCardCount[Index] = 8
		 * ; CardTypeResult[CT_FOUR_LINE_TAKE_TWO].cbCardTypeCount++ ;
		 * 
		 * ASSERT(CardTypeResult[CT_FOUR_LINE_TAKE_TWO].cbCardTypeCount<
		 * MAX_TYPE_COUNT) ; } } }
		 */

	}

	private void AnalyseOutCardType(int[] cbHandCardData, int cbHandCardCount, int[] cbTurnCardData, int cbTurnCardCount, tagOutCardTypeResult_Server[] CardTypeResult) {
		//// 后退youyiK


		int cbTmpCard[] = new int[Constants.MAX_COUNT];
		Constants.CopyMemory(cbTmpCard, cbHandCardData, cbHandCardCount);
		SortCardList(cbTmpCard, cbHandCardCount, Constants.ST_ORDER);
		// SortCardList(cbTurnCardData, cbTurnCardCount, ST_ORDER) ;

		int cbTurnCardType = GetCardType(cbTurnCardData, cbTurnCardCount);

		if (cbTurnCardType == Constants.CT_ERROR)
			return;

		if (cbTurnCardType != Constants.CT_MISSILE_CARD && cbTurnCardType != Constants.CT_BOMB_CARD) {
			// 双王炸弹
			if (cbHandCardCount >= 2 && 0x4F == cbTmpCard[0] && 0x4E == cbTmpCard[1]) {
				int Index = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardType = Constants.CT_BOMB_CARD;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index][0] = cbTmpCard[0];
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index][1] = cbTmpCard[1];
				CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[Index] = 2;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount++;

				int cbBomCardData[] = new int[Constants.MAX_COUNT];
				int cbBomCardCount = 0;
				cbBomCardCount = GetAllBomCard(cbTmpCard, 2, cbHandCardCount - 2, cbBomCardData, cbBomCardCount);
				for (int i = 0; i < cbBomCardCount / 4; ++i) {
					Index = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount;
					CardTypeResult[Constants.CT_BOMB_CARD].cbCardType = Constants.CT_BOMB_CARD;
					Constants.CopyMemory(CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index], 0, cbBomCardData,
							4 * i, 4);
					CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[Index] = 4;
					CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount++;

					// ASSERT(CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount<=Constants.MAX_TYPE_COUNT)
					// ;
				}
			}
			// 炸弹牌型
			else {
				int cbBomCardData[] = new int[Constants.MAX_COUNT];
				int cbBomCardCount = 0;
				cbBomCardCount = GetAllBomCard(cbTmpCard, cbHandCardCount, cbBomCardData, cbBomCardCount);
				for (int i = 0; i < cbBomCardCount / 4; ++i) {
					int Index = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount;
					CardTypeResult[Constants.CT_BOMB_CARD].cbCardType = Constants.CT_BOMB_CARD;
					Constants.CopyMemory(CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index], 0, cbBomCardData,
							4 * i, 4);
					CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[Index] = 4;
					CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount++;

					// ASSERT(CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount<=Constants.MAX_TYPE_COUNT)
					// ;
				}
			}
		}

		switch (cbTurnCardType) {
		case Constants.CT_SINGLE: // 单牌类型
		{
			for (int i = 0; i < cbHandCardCount; ++i)
				if (GetCardLogicValue(cbTmpCard[i]) > GetCardLogicValue(cbTurnCardData[0])) {
					int Index = CardTypeResult[Constants.CT_SINGLE].cbCardTypeCount;
					CardTypeResult[Constants.CT_SINGLE].cbCardType = Constants.CT_SINGLE;
					CardTypeResult[Constants.CT_SINGLE].cbCardData[Index][0] = cbTmpCard[i];
					CardTypeResult[Constants.CT_SINGLE].cbEachHandCardCount[Index] = 1;
					CardTypeResult[Constants.CT_SINGLE].cbCardTypeCount++;

					// ASSERT(CardTypeResult[Constants.CT_SINGLE].cbCardTypeCount<=Constants.MAX_TYPE_COUNT)
					// ;
				}
			break;
		}
		case Constants.CT_DOUBLE: // 对牌类型
		{
			// 扑克分析
			for (int i = 0; i < cbHandCardCount; i++) {
				// 变量定义
				int cbSameCount = 1;
				int cbLogicValue = GetCardLogicValue(cbTmpCard[i]);

				// 搜索同牌
				for (int j = i + 1; j < cbHandCardCount; j++) {
					// 获取扑克
					if (GetCardLogicValue(cbTmpCard[j]) != cbLogicValue)
						break;

					// 设置变量
					cbSameCount++;
				}

				if (cbSameCount >= 2 && GetCardLogicValue(cbTmpCard[i]) > GetCardLogicValue(cbTurnCardData[0])) {
					int Index = CardTypeResult[Constants.CT_DOUBLE].cbCardTypeCount;
					CardTypeResult[Constants.CT_DOUBLE].cbCardType = Constants.CT_DOUBLE;
					CardTypeResult[Constants.CT_DOUBLE].cbCardData[Index][0] = cbTmpCard[i];
					CardTypeResult[Constants.CT_DOUBLE].cbCardData[Index][1] = cbTmpCard[i + 1];
					CardTypeResult[Constants.CT_DOUBLE].cbEachHandCardCount[Index] = 2;
					CardTypeResult[Constants.CT_DOUBLE].cbCardTypeCount++;

					// ASSERT(CardTypeResult[Constants.CT_DOUBLE].cbCardTypeCount<=Constants.MAX_TYPE_COUNT)
					// ;
				}
				// 设置索引
				i += cbSameCount - 1;
			}
			break;
		}
		case Constants.CT_THREE: // 三条类型
		{
			// 扑克分析
			for (int i = 0; i < cbHandCardCount; i++) {
				// 变量定义
				int cbSameCount = 1;
				int cbLogicValue = GetCardLogicValue(cbTmpCard[i]);

				// 搜索同牌
				for (int j = i + 1; j < cbHandCardCount; j++) {
					// 获取扑克
					if (GetCardLogicValue(cbTmpCard[j]) != cbLogicValue)
						break;

					// 设置变量
					cbSameCount++;
				}

				if (cbSameCount >= 3 && GetCardLogicValue(cbTmpCard[i]) > GetCardLogicValue(cbTurnCardData[0])) {
					int Index = CardTypeResult[Constants.CT_THREE].cbCardTypeCount;
					CardTypeResult[Constants.CT_THREE].cbCardType = Constants.CT_THREE;
					CardTypeResult[Constants.CT_THREE].cbCardData[Index][0] = cbTmpCard[i];
					CardTypeResult[Constants.CT_THREE].cbCardData[Index][1] = cbTmpCard[i + 1];
					CardTypeResult[Constants.CT_THREE].cbCardData[Index][2] = cbTmpCard[i + 2];
					CardTypeResult[Constants.CT_THREE].cbEachHandCardCount[Index] = 3;
					CardTypeResult[Constants.CT_THREE].cbCardTypeCount++;

					// ASSERT(CardTypeResult[Constants.CT_THREE].cbCardTypeCount<=Constants.MAX_TYPE_COUNT)
					// ;
				}
				// 设置索引
				i += cbSameCount - 1;
			}
			break;
		}
		case Constants.CT_SINGLE_LINE: // 单连类型
		{
			int cbFirstCard = 0;
			// 去除2和王
			for (int i = 0; i < cbHandCardCount; ++i)
				if (GetCardLogicValue(cbTmpCard[i]) < 15) {
					cbFirstCard = i;
					break;
				}

			int cbSingleLineCard[] = new int[12];
			int cbSingleLineCount = 1;
			int cbLeftCardCount = cbHandCardCount;
			boolean bFindSingleLine = true;

			// 连牌判断
			while (cbLeftCardCount >= cbTurnCardCount && bFindSingleLine) {
				cbSingleLineCount = 1;
				bFindSingleLine = false;
				int cbLastCard = cbTmpCard[cbFirstCard];
				cbSingleLineCard[cbSingleLineCount - 1] = cbTmpCard[cbFirstCard];
				for (int i = cbFirstCard + 1; i < cbLeftCardCount; i++) {
					int cbCardData = cbTmpCard[i];

					// 连续判断
					if (1 != (GetCardLogicValue(cbLastCard) - GetCardLogicValue(cbCardData))
							&& GetCardValue(cbLastCard) != GetCardValue(cbCardData)) {
						cbLastCard = cbTmpCard[i];
						// 是否合法
						if (cbSingleLineCount < cbTurnCardCount) {
							cbSingleLineCount = 1;
							cbSingleLineCard[cbSingleLineCount - 1] = cbTmpCard[i];
							continue;
						} else
							break;
					}
					// 同牌判断
					else if (GetCardValue(cbLastCard) != GetCardValue(cbCardData)) {
						cbLastCard = cbCardData;
						cbSingleLineCard[cbSingleLineCount] = cbCardData;
						++cbSingleLineCount;
					}
				}

				// 保存数据
				if (cbSingleLineCount >= cbTurnCardCount
						&& GetCardLogicValue(cbSingleLineCard[0]) > GetCardLogicValue(cbTurnCardData[0])) {
					int Index;
					int cbStart = 0;
					// 所有连牌
					while (GetCardLogicValue(cbSingleLineCard[cbStart]) > GetCardLogicValue(cbTurnCardData[0])
							&& ((cbSingleLineCount - cbStart) >= cbTurnCardCount)) {
						Index = CardTypeResult[Constants.CT_SINGLE_LINE].cbCardTypeCount;
						CardTypeResult[Constants.CT_SINGLE_LINE].cbCardType = Constants.CT_SINGLE_LINE;
						Constants.CopyMemory(CardTypeResult[Constants.CT_SINGLE_LINE].cbCardData[Index], 0,
								cbSingleLineCard, cbStart, cbTurnCardCount);
						CardTypeResult[Constants.CT_SINGLE_LINE].cbEachHandCardCount[Index] = cbTurnCardCount;
						CardTypeResult[Constants.CT_SINGLE_LINE].cbCardTypeCount++;
						cbStart++;

						// ASSERT(CardTypeResult[CT_SINGLE_LINE].cbCardTypeCount<=MAX_TYPE_COUNT)
						// ;
					}

					RemoveCard(cbSingleLineCard, cbSingleLineCount, cbTmpCard, cbLeftCardCount);
					cbLeftCardCount -= cbSingleLineCount;
					bFindSingleLine = true;
				}
			}

			break;
		}
		case Constants.CT_DOUBLE_LINE: // 对连类型
		{
			// 连牌判断
			int cbFirstCard = 0;
			// 去除2和王
			for (int i = 0; i < cbHandCardCount; ++i)
				if (GetCardLogicValue(cbTmpCard[i]) < 15) {
					cbFirstCard = i;
					break;
				}

			int cbLeftCardCount = cbHandCardCount - cbFirstCard;
			boolean bFindDoubleLine = true;
			int cbDoubleLineCount = 0;
			int cbDoubleLineCard[] = new int[24];
			// 开始判断
			while (cbLeftCardCount >= cbTurnCardCount && bFindDoubleLine) {
				int cbLastCard = cbTmpCard[cbFirstCard];
				int cbSameCount = 1;
				cbDoubleLineCount = 0;
				bFindDoubleLine = false;
				for (int i = cbFirstCard + 1; i < cbLeftCardCount + cbFirstCard; ++i) {
					// 搜索同牌
					while (GetCardValue(cbLastCard) == GetCardValue(cbTmpCard[i])
							&& i < cbLeftCardCount + cbFirstCard) {
						++cbSameCount;
						++i;
					}

					int cbLastDoubleCardValue = 0;
					if (cbDoubleLineCount > 0)
						cbLastDoubleCardValue = GetCardLogicValue(cbDoubleLineCard[cbDoubleLineCount - 1]);
					// 重新开始
					if ((cbSameCount < 2
							|| (cbDoubleLineCount > 0 && (cbLastDoubleCardValue - GetCardLogicValue(cbLastCard)) != 1))
							&& i <= cbLeftCardCount + cbFirstCard) {
						if (cbDoubleLineCount >= cbTurnCardCount)
							break;

						if (cbSameCount >= 2)
							i -= cbSameCount;

						cbLastCard = cbTmpCard[i];
						cbDoubleLineCount = 0;
					}
					// 保存数据
					else if (cbSameCount >= 2) {
						cbDoubleLineCard[cbDoubleLineCount] = cbTmpCard[i - cbSameCount];
						cbDoubleLineCard[cbDoubleLineCount + 1] = cbTmpCard[i - cbSameCount + 1];
						cbDoubleLineCount += 2;

						// 结尾判断
						if (i == (cbLeftCardCount + cbFirstCard - 2))
							if ((GetCardLogicValue(cbLastCard) - GetCardLogicValue(cbTmpCard[i])) == 1
									&& (GetCardLogicValue(cbTmpCard[i]) == GetCardLogicValue(cbTmpCard[i + 1]))) {
								cbDoubleLineCard[cbDoubleLineCount] = cbTmpCard[i];
								cbDoubleLineCard[cbDoubleLineCount + 1] = cbTmpCard[i + 1];
								cbDoubleLineCount += 2;
								break;
							}

					}

					cbLastCard = cbTmpCard[i];
					cbSameCount = 1;
				}

				// 保存数据
				if (cbDoubleLineCount >= cbTurnCardCount) {
					int Index;
					int cbStart = 0;
					// 所有连牌
					while (GetCardLogicValue(cbDoubleLineCard[cbStart]) > GetCardLogicValue(cbTurnCardData[0])
							&& ((cbDoubleLineCount - cbStart) >= cbTurnCardCount)) {
						Index = CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardTypeCount;
						CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardType = Constants.CT_DOUBLE_LINE;
						Constants.CopyMemory(CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardData[Index], 0,
								cbDoubleLineCard, cbStart, cbTurnCardCount);
						CardTypeResult[Constants.CT_DOUBLE_LINE].cbEachHandCardCount[Index] = cbTurnCardCount;
						CardTypeResult[Constants.CT_DOUBLE_LINE].cbCardTypeCount++;
						cbStart += 2;

						// ASSERT(CardTypeResult[CT_DOUBLE_LINE].cbCardTypeCount<=MAX_TYPE_COUNT)
						// ;
					}
					RemoveCard(cbDoubleLineCard, cbDoubleLineCount, cbTmpCard, cbFirstCard + cbLeftCardCount);
					bFindDoubleLine = true;
					cbLeftCardCount -= cbDoubleLineCount;
				}
			}

			break;
		}
		case Constants.CT_THREE_LINE: // 三连类型
		{
			// 连牌判断
			int cbFirstCard = 0;
			// 去除2和王
			for (int i = 0; i < cbHandCardCount; ++i)
				if (GetCardLogicValue(cbTmpCard[i]) < 15) {
					cbFirstCard = i;
					break;
				}

			int cbLeftCardCount = cbHandCardCount - cbFirstCard;
			boolean bFindThreeLine = true;
			int cbThreeLineCount = 0;
			int cbThreeLineCard[] = new int[20];
			// 开始判断
			while (cbLeftCardCount >= cbTurnCardCount && bFindThreeLine) {
				int cbLastCard = cbTmpCard[cbFirstCard];
				int cbSameCount = 1;
				cbThreeLineCount = 0;
				bFindThreeLine = false;
				for (int i = cbFirstCard + 1; i < cbLeftCardCount + cbFirstCard; ++i) {
					// 搜索同牌
					while (GetCardValue(cbLastCard) == GetCardValue(cbTmpCard[i])
							&& i < cbLeftCardCount + cbFirstCard) {
						++cbSameCount;
						++i;
					}

					int cbLastThreeCardValue = 0;
					if (cbThreeLineCount > 0)
						cbLastThreeCardValue = GetCardLogicValue(cbThreeLineCard[cbThreeLineCount - 1]);

					// 重新开始
					if ((cbSameCount < 3
							|| (cbThreeLineCount > 0 && (cbLastThreeCardValue - GetCardLogicValue(cbLastCard)) != 1))
							&& i <= cbLeftCardCount + cbFirstCard) {
						if (cbThreeLineCount >= cbTurnCardCount)
							break;

						if (cbSameCount >= 3)
							i -= 3;
						cbLastCard = cbTmpCard[i];
						cbThreeLineCount = 0;
					}
					// 保存数据
					else if (cbSameCount >= 3) {
						cbThreeLineCard[cbThreeLineCount] = cbTmpCard[i - cbSameCount];
						cbThreeLineCard[cbThreeLineCount + 1] = cbTmpCard[i - cbSameCount + 1];
						cbThreeLineCard[cbThreeLineCount + 2] = cbTmpCard[i - cbSameCount + 2];
						cbThreeLineCount += 3;

						// 结尾判断
						if (i == (cbLeftCardCount + cbFirstCard - 3))
							if ((GetCardLogicValue(cbLastCard) - GetCardLogicValue(cbTmpCard[i])) == 1
									&& (GetCardLogicValue(cbTmpCard[i]) == GetCardLogicValue(cbTmpCard[i + 1]))
									&& (GetCardLogicValue(cbTmpCard[i]) == GetCardLogicValue(cbTmpCard[i + 2]))) {
								cbThreeLineCard[cbThreeLineCount] = cbTmpCard[i];
								cbThreeLineCard[cbThreeLineCount + 1] = cbTmpCard[i + 1];
								cbThreeLineCard[cbThreeLineCount + 2] = cbTmpCard[i + 2];
								cbThreeLineCount += 3;
								break;
							}

					}

					cbLastCard = cbTmpCard[i];
					cbSameCount = 1;
				}

				// 保存数据
				if (cbThreeLineCount >= cbTurnCardCount) {
					int Index;
					int cbStart = 0;
					// 所有连牌
					while (GetCardLogicValue(cbThreeLineCard[cbStart]) > GetCardLogicValue(cbTurnCardData[0])
							&& ((cbThreeLineCount - cbStart) >= cbTurnCardCount)) {
						Index = CardTypeResult[Constants.CT_THREE_LINE].cbCardTypeCount;
						CardTypeResult[Constants.CT_THREE_LINE].cbCardType = Constants.CT_THREE_LINE;
						Constants.CopyMemory(CardTypeResult[Constants.CT_THREE_LINE].cbCardData[Index], 0,
								cbThreeLineCard, cbStart, cbTurnCardCount);
						CardTypeResult[Constants.CT_THREE_LINE].cbEachHandCardCount[Index] = cbTurnCardCount;
						CardTypeResult[Constants.CT_THREE_LINE].cbCardTypeCount++;
						cbStart += 3;

						// ASSERT(CardTypeResult[CT_THREE_LINE].cbCardTypeCount<=MAX_TYPE_COUNT)
						// ;
					}

					RemoveCard(cbThreeLineCard, cbThreeLineCount, cbTmpCard, cbFirstCard + cbLeftCardCount);
					bFindThreeLine = true;
					cbLeftCardCount -= cbThreeLineCount;
				}
			}

			break;
		}
		case Constants.CT_THREE_LINE_TAKE_ONE:// 三带一单
		{
			int cbTurnThreeCard[] = new int[Constants.MAX_COUNT];
			int cbTurnThreeCount = 0;
			int cbHandThreeCard[] = new int[Constants.MAX_COUNT];
			int cbHandThreeCount = 0;
			int cbSingleCardCount = cbTurnCardCount / 4;

			// 移除炸弹
			int cbAllBomCardData[] = new int[Constants.MAX_COUNT];
			int cbAllBomCardCount = 0;
			cbAllBomCardCount = GetAllBomCard(cbTmpCard, cbHandCardCount, cbAllBomCardData, cbAllBomCardCount);
			RemoveCard(cbAllBomCardData, cbAllBomCardCount, cbTmpCard, cbHandCardCount);

			// 三条扑克
			cbTurnThreeCount = GetAllThreeCard(cbTurnCardData, cbTurnCardCount, cbTurnThreeCard, cbTurnThreeCount);

			int cbFirstCard = 0;

			// 去除2和王
			if (cbTurnThreeCount > 3)
				for (int i = 0; i < cbHandCardCount - cbAllBomCardCount; ++i)
					if (GetCardLogicValue(cbTmpCard[i]) < 15) {
						cbFirstCard = i;
						break;
					}

			cbHandThreeCount = GetAllThreeCard(cbTmpCard, cbFirstCard,
					cbHandCardCount - cbFirstCard - cbAllBomCardCount, cbHandThreeCard, cbHandThreeCount);

			if (cbHandThreeCount < cbTurnThreeCount || (cbHandThreeCount > 0
					&& GetCardLogicValue(cbHandThreeCard[0]) < GetCardLogicValue(cbTurnThreeCard[0])))
				return;

			for (int i = 0; i < cbHandThreeCount; i += 3) {
				int cbLastLogicCard = GetCardLogicValue(cbHandThreeCard[i]);
				int cbThreeLineCard[] = new int[Constants.MAX_COUNT];
				int cbThreeLineCardCount = 3;
				cbThreeLineCard[0] = cbHandThreeCard[i];
				cbThreeLineCard[1] = cbHandThreeCard[i + 1];
				cbThreeLineCard[2] = cbHandThreeCard[i + 2];
				for (int j = i + 3; j < cbHandThreeCount; j += 3) {
					// 连续判断
					if (1 != (cbLastLogicCard - (GetCardLogicValue(cbHandThreeCard[j])))
							|| cbThreeLineCardCount == cbTurnThreeCount)
						break;

					cbLastLogicCard = GetCardLogicValue(cbHandThreeCard[j]);
					cbThreeLineCard[cbThreeLineCardCount] = cbHandThreeCard[j];
					cbThreeLineCard[cbThreeLineCardCount + 1] = cbHandThreeCard[j + 1];
					cbThreeLineCard[cbThreeLineCardCount + 2] = cbHandThreeCard[j + 2];
					cbThreeLineCardCount += 3;
				}
				if (cbThreeLineCardCount == cbTurnThreeCount
						&& GetCardLogicValue(cbThreeLineCard[0]) > GetCardLogicValue(cbTurnThreeCard[0])) {
					int Index;

					int cbRemainCard[] = new int[Constants.MAX_COUNT];
					Constants.CopyMemory(cbRemainCard, cbTmpCard, (cbHandCardCount - cbAllBomCardCount));
					RemoveCard(cbThreeLineCard, cbTurnThreeCount, cbRemainCard, (cbHandCardCount - cbAllBomCardCount));

					// 单牌组合
					int cbComCard[] = new int[5];
					int cbComResCard[][] = new int[254][5];
					int cbComResLen = 0;
					cbComResLen = Combination(cbComCard, 0, cbComResCard, cbComResLen, cbRemainCard, cbSingleCardCount,
							(cbHandCardCount - cbAllBomCardCount) - cbTurnThreeCount, cbSingleCardCount);
					for (int i1 = 0; i1 < cbComResLen; ++i1) {
						Index = CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardTypeCount;
						CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardType = Constants.CT_THREE_LINE_TAKE_ONE;
						// 保存三条
						Constants.CopyMemory(CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardData[Index],
								cbThreeLineCard, cbTurnThreeCount);
						// 保存单牌
						Constants.CopyMemory(CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardData[Index],
								cbTurnThreeCount, cbComResCard[i1], cbSingleCardCount);

						// ASSERT(cbTurnThreeCount+cbSingleCardCount==cbTurnCardCount)
						// ;
						CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbEachHandCardCount[Index] = cbTurnCardCount;
						CardTypeResult[Constants.CT_THREE_LINE_TAKE_ONE].cbCardTypeCount++;

						// ASSERT(CardTypeResult[CT_THREE_LINE_TAKE_ONE].cbCardTypeCount<=MAX_TYPE_COUNT)
						// ;
					}

				}
			}

			break;
		}
		case Constants.CT_THREE_LINE_TAKE_TWO:// 三带一对
		{
			int cbTurnThreeCard[] = new int[Constants.MAX_COUNT];
			int cbTurnThreeCount = 0;
			int cbHandThreeCard[] = new int[Constants.MAX_COUNT];
			int cbHandThreeCount = 0;
			int cbDoubleCardCount = cbTurnCardCount / 5;

			// 三条扑克
			cbTurnThreeCount = GetAllThreeCard(cbTurnCardData, cbTurnCardCount, cbTurnThreeCard, cbTurnThreeCount);

			int cbFirstCard = 0;

			// 去除2和王
			if (cbTurnThreeCount > 3)
				for (int i = 0; i < cbHandCardCount; ++i)
					if (GetCardLogicValue(cbTmpCard[i]) < 15) {
						cbFirstCard = i;
						break;
					}

			cbHandThreeCount = GetAllThreeCard(cbTmpCard, cbFirstCard, cbHandCardCount - cbFirstCard, cbHandThreeCard,
					cbHandThreeCount);

			if (cbHandThreeCount < cbTurnThreeCount || (cbHandThreeCount > 0
					&& GetCardLogicValue(cbHandThreeCard[0]) < GetCardLogicValue(cbTurnThreeCard[0])))
				return;

			for (int i = 0; i < cbHandThreeCount; i += 3) {
				int cbLastLogicCard = GetCardLogicValue(cbHandThreeCard[i]);
				int cbThreeLineCard[] = new int[Constants.MAX_COUNT];
				int cbThreeLineCardCount = 3;
				cbThreeLineCard[0] = cbHandThreeCard[i];
				cbThreeLineCard[1] = cbHandThreeCard[i + 1];
				cbThreeLineCard[2] = cbHandThreeCard[i + 2];
				for (int j = i + 3; j < cbHandThreeCount; j += 3) {
					// 连续判断
					if (1 != (cbLastLogicCard - (GetCardLogicValue(cbHandThreeCard[j])))
							|| cbThreeLineCardCount == cbTurnThreeCount)
						break;

					cbLastLogicCard = GetCardLogicValue(cbHandThreeCard[j]);
					cbThreeLineCard[cbThreeLineCardCount] = cbHandThreeCard[j];
					cbThreeLineCard[cbThreeLineCardCount + 1] = cbHandThreeCard[j + 1];
					cbThreeLineCard[cbThreeLineCardCount + 2] = cbHandThreeCard[j + 2];
					cbThreeLineCardCount += 3;
				}
				if (cbThreeLineCardCount == cbTurnThreeCount
						&& GetCardLogicValue(cbThreeLineCard[0]) > GetCardLogicValue(cbTurnThreeCard[0])) {
					int Index;

					int cbRemainCard[] = new int[Constants.MAX_COUNT];
					Constants.CopyMemory(cbRemainCard, cbTmpCard, cbHandCardCount);
					RemoveCard(cbThreeLineCard, cbTurnThreeCount, cbRemainCard, cbHandCardCount);

					int cbAllDoubleCardData[] = new int[Constants.MAX_COUNT];
					int cbAllDoubleCardCount = 0;
					cbAllDoubleCardCount = GetAllDoubleCard(cbRemainCard, cbHandCardCount - cbTurnThreeCount, cbAllDoubleCardData,
							cbAllDoubleCardCount);

					int cbDoubleCardIndex[] = new int[10]; // 对牌下标
					for (int i1 = 0, j = 0; i1 < cbAllDoubleCardCount; i1 += 2, ++j)
						cbDoubleCardIndex[j] = i1;

					// 对牌组合
					int cbComCard[] = new int[5];
					int cbComResCard[][] = new int[254][5];
					int cbComResLen = 0;

					// 利用对牌的下标做组合，再根据下标提取出对牌
					Combination(cbComCard, 0, cbComResCard, cbComResLen, cbDoubleCardIndex, cbDoubleCardCount,
							cbAllDoubleCardCount / 2, cbDoubleCardCount);
					for (int i1 = 0; i1 < cbComResLen; ++i1) {
						Index = CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardTypeCount;
						CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardType = Constants.CT_THREE_LINE_TAKE_TWO;
						// 保存三条
						Constants.CopyMemory(CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardData[Index],
								cbThreeLineCard, cbTurnThreeCount);
						// 保存对牌
						for (int j = 0, k = 0; j < cbDoubleCardCount; ++j, k += 2) {
							CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardData[Index][cbTurnThreeCount
									+ k] = cbAllDoubleCardData[cbComResCard[i1][j]];
							CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardData[Index][cbTurnThreeCount + k
									+ 1] = cbAllDoubleCardData[cbComResCard[i1][j] + 1];
						}

						// ASSERT(cbTurnThreeCount+cbDoubleCardCount*2==cbTurnCardCount)
						// ;
						CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbEachHandCardCount[Index] = cbTurnCardCount;

						CardTypeResult[Constants.CT_THREE_LINE_TAKE_TWO].cbCardTypeCount++;

						// ASSERT(CardTypeResult[CT_THREE_LINE_TAKE_TWO].cbCardTypeCount<=MAX_TYPE_COUNT)
						// ;
					}

				}
			}

			break;
		}
		case Constants.CT_FOUR_LINE_TAKE_ONE:// 四带两单
		{
			int cbFirstCard = 0;
			// 去除王牌
			for (int i = 0; i < cbHandCardCount; ++i)
				if (GetCardColor(cbTmpCard[i]) != 0x40) {
					cbFirstCard = i;
					break;
				}

			int cbHandAllFourCardData[] = new int[Constants.MAX_COUNT];
			int cbHandAllFourCardCount = 0;
			int cbTurnAllFourCardData[] = new int[Constants.MAX_COUNT];
			int cbTurnAllFourCardCount = 0;
			// 抽取四张
			cbHandAllFourCardCount = GetAllBomCard(cbTmpCard, cbFirstCard, cbHandCardCount - cbFirstCard,
					cbHandAllFourCardData, cbHandAllFourCardCount);
			cbTurnAllFourCardCount = GetAllBomCard(cbTurnCardData, cbTurnCardCount, cbTurnAllFourCardData,
					cbTurnAllFourCardCount);

			if (cbHandAllFourCardCount > 0
					&& GetCardLogicValue(cbHandAllFourCardData[0]) < GetCardLogicValue(cbTurnAllFourCardData[0]))
				return;

			int cbCanOutFourCardData[] = new int[Constants.MAX_COUNT];
			int cbCanOutFourCardCount = 0;
			// 可出的牌
			for (int i = 0; i < cbHandAllFourCardCount; i += 4) {
				if (GetCardLogicValue(cbHandAllFourCardData[i]) > GetCardLogicValue(cbTurnAllFourCardData[0])) {
					cbCanOutFourCardData[cbCanOutFourCardCount] = cbHandAllFourCardData[i];
					cbCanOutFourCardData[cbCanOutFourCardCount + 1] = cbHandAllFourCardData[i + 1];
					cbCanOutFourCardData[cbCanOutFourCardCount + 2] = cbHandAllFourCardData[i + 2];
					cbCanOutFourCardData[cbCanOutFourCardCount + 3] = cbHandAllFourCardData[i + 3];
					cbCanOutFourCardCount += 4;
				}
			}

			if ((cbHandCardCount - cbCanOutFourCardCount) < (cbTurnCardCount - cbTurnAllFourCardCount))
				return;

			int cbRemainCard[] = new int[Constants.MAX_COUNT];
			Constants.CopyMemory(cbRemainCard, cbTmpCard, cbHandCardCount);
			RemoveCard(cbCanOutFourCardData, cbCanOutFourCardCount, cbRemainCard, cbHandCardCount);
			for (int Start = 0; Start < cbCanOutFourCardCount; Start += 4) {
				int Index;
				// 单牌组合
				int cbComCard[] = new int[5];
				int cbComResCard[][] = new int[254][5];
				int cbComResLen = 0;
				// 单牌组合
				Combination(cbComCard, 0, cbComResCard, cbComResLen, cbRemainCard, 2,
						cbHandCardCount - cbCanOutFourCardCount, 2);
				for (int i = 0; i < cbComResLen; ++i) {
					// 不能带对
					if (GetCardValue(cbComResCard[i][0]) == GetCardValue(cbComResCard[i][1]))
						continue;

					Index = CardTypeResult[Constants.CT_FOUR_LINE_TAKE_ONE].cbCardTypeCount;
					CardTypeResult[Constants.CT_FOUR_LINE_TAKE_ONE].cbCardType = Constants.CT_FOUR_LINE_TAKE_ONE;
					Constants.CopyMemory(CardTypeResult[Constants.CT_FOUR_LINE_TAKE_ONE].cbCardData[Index], 0,
							cbCanOutFourCardData, Start, 4);
					CardTypeResult[Constants.CT_FOUR_LINE_TAKE_ONE].cbCardData[Index][4] = cbComResCard[i][0];
					CardTypeResult[Constants.CT_FOUR_LINE_TAKE_ONE].cbCardData[Index][4 + 1] = cbComResCard[i][1];
					CardTypeResult[Constants.CT_FOUR_LINE_TAKE_ONE].cbEachHandCardCount[Index] = 6;
					CardTypeResult[Constants.CT_FOUR_LINE_TAKE_ONE].cbCardTypeCount++;

					// ASSERT(CardTypeResult[CT_FOUR_LINE_TAKE_ONE].cbCardTypeCount<=MAX_TYPE_COUNT)
					// ;
				}
			}

			break;
		}
		case Constants.CT_FOUR_LINE_TAKE_TWO:// 四带两对
		{
			int cbFirstCard = 0;
			// 去除王牌
			for (int i = 0; i < cbHandCardCount; ++i)
				if (GetCardColor(cbTmpCard[i]) != 0x40) {
					cbFirstCard = i;
					break;
				}

			int cbHandAllFourCardData[] = new int[Constants.MAX_COUNT];
			int cbHandAllFourCardCount = 0;
			int cbTurnAllFourCardData[] = new int[Constants.MAX_COUNT];
			int cbTurnAllFourCardCount = 0;
			// 抽取四张
			cbHandAllFourCardCount = GetAllBomCard(cbTmpCard, cbFirstCard, cbHandCardCount - cbFirstCard,
					cbHandAllFourCardData, cbHandAllFourCardCount);
			cbTurnAllFourCardCount = GetAllBomCard(cbTurnCardData, cbTurnCardCount, cbTurnAllFourCardData,
					cbTurnAllFourCardCount);

			if (cbHandAllFourCardCount > 0
					&& GetCardLogicValue(cbHandAllFourCardData[0]) < GetCardLogicValue(cbTurnAllFourCardData[0]))
				return;

			int cbCanOutFourCardData[] = new int[Constants.MAX_COUNT];
			int cbCanOutFourCardCount = 0;
			// 可出的牌
			for (int i = 0; i < cbHandAllFourCardCount; i += 4) {
				if (GetCardLogicValue(cbHandAllFourCardData[i]) > GetCardLogicValue(cbTurnAllFourCardData[0])) {
					cbCanOutFourCardData[cbCanOutFourCardCount] = cbHandAllFourCardData[i];
					cbCanOutFourCardData[cbCanOutFourCardCount + 1] = cbHandAllFourCardData[i + 1];
					cbCanOutFourCardData[cbCanOutFourCardCount + 2] = cbHandAllFourCardData[i + 2];
					cbCanOutFourCardData[cbCanOutFourCardCount + 3] = cbHandAllFourCardData[i + 3];
					cbCanOutFourCardCount += 4;
				}
			}

			if ((cbHandCardCount - cbCanOutFourCardCount) < (cbTurnCardCount - cbTurnAllFourCardCount))
				return;

			int cbRemainCard[] = new int[Constants.MAX_COUNT];
			Constants.CopyMemory(cbRemainCard, cbTmpCard, cbHandCardCount);
			RemoveCard(cbCanOutFourCardData, cbCanOutFourCardCount, cbRemainCard, cbHandCardCount);
			for (int Start = 0; Start < cbCanOutFourCardCount; Start += 4) {
				int cbAllDoubleCardData[] = new int[Constants.MAX_COUNT];
				int cbAllDoubleCardCount = 0;
				cbAllDoubleCardCount = GetAllDoubleCard(cbRemainCard, cbHandCardCount - cbCanOutFourCardCount, cbAllDoubleCardData,
						cbAllDoubleCardCount);

				int cbDoubleCardIndex[] = new int[10]; // 对牌下标
				for (int i = 0, j = 0; i < cbAllDoubleCardCount; i += 2, ++j)
					cbDoubleCardIndex[j] = i;

				// 对牌组合
				int cbComCard[] = new int[5];
				int cbComResCard[][] = new int[254][5];
				int cbComResLen = 0;

				// 利用对牌的下标做组合，再根据下标提取出对牌
				Combination(cbComCard, 0, cbComResCard, cbComResLen, cbDoubleCardIndex, 2, cbAllDoubleCardCount / 2, 2);
				for (int i = 0; i < cbComResLen; ++i) {
					int Index = CardTypeResult[Constants.CT_FOUR_LINE_TAKE_TWO].cbCardTypeCount;
					CardTypeResult[Constants.CT_FOUR_LINE_TAKE_TWO].cbCardType = Constants.CT_FOUR_LINE_TAKE_TWO;
					Constants.CopyMemory(CardTypeResult[Constants.CT_FOUR_LINE_TAKE_TWO].cbCardData[Index], 0,
							cbCanOutFourCardData, Start, 4);

					// 保存对牌
					for (int j = 0, k = 0; j < 4; ++j, k += 2) {
						CardTypeResult[Constants.CT_FOUR_LINE_TAKE_TWO].cbCardData[Index][4
								+ k] = cbAllDoubleCardData[cbComResCard[i][j]];
						CardTypeResult[Constants.CT_FOUR_LINE_TAKE_TWO].cbCardData[Index][4 + k
								+ 1] = cbAllDoubleCardData[cbComResCard[i][j] + 1];
					}

					CardTypeResult[Constants.CT_FOUR_LINE_TAKE_TWO].cbEachHandCardCount[Index] = 8;
					CardTypeResult[Constants.CT_FOUR_LINE_TAKE_TWO].cbCardTypeCount++;

					// ASSERT(CardTypeResult[Constants.CT_FOUR_LINE_TAKE_TWO].cbCardTypeCount<=Constants.MAX_TYPE_COUNT)
					// ;
				}
			}
			break;
		}
		case Constants.CT_BOMB_CARD: // 炸弹类型
		{
			int cbAllBomCardData[] = new int[Constants.MAX_COUNT];
			int cbAllBomCardCount = 0;
			cbAllBomCardCount = GetAllBomCard(cbTmpCard, cbHandCardCount, cbAllBomCardData, cbAllBomCardCount);
			int cbFirstBom = 0;
			int Index;
			if (cbAllBomCardCount > 0 && cbAllBomCardData[0] == 0x4F) {
				Index = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardType = Constants.CT_BOMB_CARD;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index][0] = 0x4F;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index][1] = 0x4E;
				CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[Index] = 2;
				CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount++;

				// ASSERT(CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount<=Constants.MAX_TYPE_COUNT)
				// ;
				cbFirstBom = 2;
			}
			for (int i = cbFirstBom; i < cbAllBomCardCount; i += 4) {
				if (GetCardLogicValue(cbAllBomCardData[i]) > GetCardLogicValue(cbTurnCardData[0])) {
					Index = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount;
					CardTypeResult[Constants.CT_BOMB_CARD].cbCardType = Constants.CT_BOMB_CARD;
					Constants.CopyMemory(CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[Index], 0, cbAllBomCardData,
							i, 4);
					CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[Index] = 4;
					CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount++;

					// ASSERT(CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount<=Constants.MAX_TYPE_COUNT)
					// ;
				}
			}
			break;
		}
		case Constants.CT_MISSILE_CARD: // 火箭类型
		{
			// 没有比火箭更大的牌了
			break;
		}
		default:
			// ASSERT(false) ;
			break;
		}

	}

	// 分析出牌
	void AnalyseOutCardType(int cbHandCardData[], int cbHandCardCount,int youyiK, tagOutCardTypeResult_Server CardTypeResult[]) {
		cbHandCardData = Constants.ArrayAdd(cbHandCardData, youyiK);
		AnalyseOutCardType(cbHandCardData, cbHandCardCount, CardTypeResult);
	}

	// 分析牌型
	void AnalyseOutCardType(int cbHandCardData[], int cbHandCardCount, int cbTurnCardData[], int cbTurnCardCount,int youyiK, tagOutCardTypeResult_Server CardTypeResult[]) {

		cbTurnCardData = Constants.ArrayAdd(cbTurnCardData, youyiK);
		AnalyseOutCardType(cbHandCardData, cbHandCardCount, cbTurnCardData, cbTurnCardCount, CardTypeResult);
	}

	/********************************************************************
	 * 函数名：Combination 参数： cbCombineCardData：存储单个的组合结果
	 * cbResComLen：已得到的组合长度，开始调用时此参数为0 cbResultCardData：存储所有的组合结果
	 * cbResCardLen：cbResultCardData的第一下标的长度，组合结果的个数 cbSrcCardData：需要做组合的数据
	 * cbSrcLen：cbSrcCardData的数据数目 cbCombineLen2，cbCombineLen1：组合的长度，开始调用时两者相等。
	 *********************************************************************/
	// 组合算法
	private int Combination(int cbCombineCardData[], int cbResComLen, int cbResultCardData[][], int cbResCardLen,int cbSrcCardData[], int cbCombineLen1, int cbSrcLen, int cbCombineLen2) {

		if (cbResComLen == cbCombineLen2) {
			Constants.CopyMemory(cbResultCardData[cbResCardLen], cbCombineCardData, cbResComLen);
			++cbResCardLen;

		} else {
			if (cbCombineLen1 >= 1 && cbSrcLen > 0 && (cbSrcLen + 1) >= 0) {
				cbCombineCardData[cbCombineLen2 - cbCombineLen1] = cbSrcCardData[0];
				++cbResComLen;
				cbResCardLen = Combination(cbCombineCardData, cbResComLen, cbResultCardData, cbResCardLen, cbSrcCardData, 1,
						cbCombineLen1 - 1, cbSrcLen - 1, cbCombineLen2);

				--cbResComLen;
				cbResCardLen = Combination(cbCombineCardData, cbResComLen, cbResultCardData, cbResCardLen, cbSrcCardData, 1,
						cbCombineLen1, cbSrcLen - 1, cbCombineLen2);
			}
		}
		
		return cbResCardLen;
	}

	private int Combination(int[] cbCombineCardData, int cbResComLen, int[][] cbResultCardData, int cbResCardLen,int[] cbSrcCardData, int i, int cbCombineLen1, int cbSrcLen, int cbCombineLen2) {
		cbSrcCardData = Constants.ArrayAdd(cbSrcCardData, i);
		return Combination(cbCombineCardData, cbResComLen, cbResultCardData, cbResCardLen, cbSrcCardData,
				cbCombineLen1, cbSrcLen, cbCombineLen2);
	}

	// 排列算法
	int Permutation(int[] list, int m, int n, int result[][], int len) {
		int j, temp;
		if (m == n) {
			for (j = 0; j < n; j++)
				result[len][j] = list[j];
			len++;
		} else {
			for (j = m; j < n; j++) {
				temp = list[m];
				list[m] = list[j];
				list[j] = temp;
				len = Permutation(list, m + 1, n, result, len);
				temp = list[m];
				list[m] = list[j];
				list[j] = temp;
			}
		}
		return len;
	}

	int GetAllBomCard = 1;
	int GetAllLineCard = 2;
	int GetAllThreeCard = 3;
	int GetAllDoubleCard = 4;

	// 地主上家（后出牌）
	private int AnalyseSinleCardCount(int[] cbHandCardData, int cbHandCardCount, int[] cbWantOutCardData, int cbWantOutCardCount) {
		return AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, cbWantOutCardData, cbWantOutCardCount, null);
	}
	// 单牌个数
	int AnalyseSinleCardCount(int cbHandCardData[], int cbHandCardCount, int cbWantOutCardData[],
			int cbWantOutCardCount, int cbSingleCardData[]) {
		// 参数判断
		// ASSERT(cbHandCardCount>0);if(cbHandCardCount<=0)return MAX_COUNT+5;

		int cbRemainCard[] = new int[Constants.MAX_COUNT];
		int cbRemainCardCount = 0;
		Constants.CopyMemory(cbRemainCard, cbHandCardData, cbHandCardCount);
		SortCardList(cbRemainCard, cbHandCardCount, Constants.ST_ORDER);

		// 移除扑克
		if (cbWantOutCardCount != 0)
			RemoveCard(cbWantOutCardData, cbWantOutCardCount, cbRemainCard, cbHandCardCount);
		cbRemainCardCount = cbHandCardCount - cbWantOutCardCount;

		// 指针数组
		int GetAllCardFunArray[] = new int[4];
		GetAllCardFunArray[0] = GetAllBomCard; // 炸弹函数
		GetAllCardFunArray[1] = GetAllLineCard; // 顺子函数
		GetAllCardFunArray[2] = GetAllThreeCard; // 三条函数
		GetAllCardFunArray[3] = GetAllDoubleCard; // 对子函数

		// 指针数组下标
		int cbIndexArray[] = { 0, 1, 2, 3 };
		// 排列结果
		int cbPermutationRes[][] = new int[24][4];
		int cbLen = 0;
		// 计算排列
		cbLen = Permutation(cbIndexArray, 0, 4, cbPermutationRes, cbLen);
		// ASSERT(cbLen==24);
		if (cbLen != 24)
			return Constants.MAX_COUNT + 5;

		// 单牌数目
		int cbMinSingleCardCount = Constants.MAX_COUNT + 5;
		// 计算最小值
		for (int i = 0; i < 24; ++i) {
			// 保留数据
			int cbTmpCardData[] = new int[Constants.MAX_COUNT];
			int cbTmpCardCount = cbRemainCardCount;
			Constants.CopyMemory(cbTmpCardData, cbRemainCard, cbRemainCardCount);

			for (int j = 0; j < 4; ++j) {
				int Index = cbPermutationRes[i][j];

				// 校验下标
				// ASSERT(Index>=0&&Index<4);
				if (Index < 0 || Index >= 4)
					return Constants.MAX_COUNT + 5;

				int pTmpGetAllCardFun = GetAllCardFunArray[Index];

				// 提取扑克
				int cbGetCardData[] = new int[Constants.MAX_COUNT];
				int cbGetCardCount = 0;
				// 成员函数
				// ((*this).*pTmpGetAllCardFun)(cbTmpCardData,cbTmpCardCount,cbGetCardData,cbGetCardCount);
				cbGetCardCount = RunFun(pTmpGetAllCardFun,cbTmpCardData,cbTmpCardCount,cbGetCardData,cbGetCardCount);
				
				

				// 删除扑克
				if (cbGetCardCount != 0)
					RemoveCard(cbGetCardData, cbGetCardCount, cbTmpCardData, cbTmpCardCount);
				cbTmpCardCount -= cbGetCardCount;
			}

			// 计算单牌
			int cbSingleCard[] = new int[Constants.MAX_COUNT];
			int cbSingleCardCount = 0;
			GetAllSingleCard(cbTmpCardData, cbTmpCardCount, cbSingleCard, cbSingleCardCount);
			if (cbMinSingleCardCount > cbSingleCardCount) {
				cbMinSingleCardCount = cbSingleCardCount;

				// 保存单牌
				if (cbSingleCardData != null) {
					Constants.CopyMemory(cbSingleCardData, cbSingleCard, cbSingleCardCount);
				}
			}
		}

		// 带大牌判断
		if (cbWantOutCardCount > 0) {
			// 出牌类型
			int cbCardType = GetCardType(cbWantOutCardData, cbWantOutCardCount);
			if (cbCardType == Constants.CT_THREE_LINE_TAKE_ONE || cbCardType == Constants.CT_THREE_LINE_TAKE_TWO)

				for (int i = 3; i < cbWantOutCardCount; ++i) {
					if (GetCardLogicValue(cbWantOutCardData[i]) >= 14)
						cbMinSingleCardCount += 3;
				}
		}

		// 拆三条判断
		if (GetCardType(cbWantOutCardData, cbWantOutCardCount) == Constants.CT_DOUBLE) {
			int cbAllThreeCardData[] = new int[Constants.MAX_COUNT], cbAllThreeCount = 0;
			int cbAllLineCardData[] = new int[Constants.MAX_COUNT], cbAllLineCount = 0;

			cbAllThreeCount = GetAllThreeCard(cbHandCardData, cbHandCardCount, cbAllThreeCardData, cbAllThreeCount);
			cbAllLineCount = GetAllLineCard(cbHandCardData, cbHandCardCount, cbAllLineCardData, cbAllLineCount);

			int cbThreeCardValue = 0;
			for (int i = 0; i < cbAllThreeCount; ++i)
				for (int j = 0; j < cbWantOutCardCount; ++j)
					if (GetCardLogicValue(cbWantOutCardData[j]) == GetCardLogicValue(cbAllThreeCardData[i])) {
						cbThreeCardValue = GetCardValue(cbWantOutCardData[j]);
						break;
					}

			// 是否有连牌
			boolean bInLineCard = false;
			for (int cbLineCardIndex = 0; cbLineCardIndex < cbAllLineCount; ++cbLineCardIndex)
				if (GetCardValue(cbAllLineCardData[cbLineCardIndex]) == cbThreeCardValue) {
					bInLineCard = true;
					break;
				}
			if (!bInLineCard && cbThreeCardValue != 0)
				cbMinSingleCardCount += 2;
		}

		// 拆炸判断
		if (cbWantOutCardCount != 0) {
			// 炸弹扑克
			int cbBombCard[] = new int[20];
			int cbBombCardCount = 0;
			cbBombCardCount = GetAllBomCard(cbHandCardData, cbHandCardCount, cbBombCard, cbBombCardCount);

			// 出牌类型
			int cbCardType = GetCardType(cbWantOutCardData, cbWantOutCardCount);

			if (cbBombCardCount > 0 && cbCardType < Constants.CT_BOMB_CARD) {
				// 寻找相同
				for (int i = GetCardColor(cbBombCard[0]) == 4 ? 2 : 0; i < cbBombCardCount; i += 4)
					for (int j = 0; j < cbWantOutCardCount; ++j) {
						if (GetCardValue(cbBombCard[i]) == GetCardValue(cbWantOutCardData[j])
								&& GetCardLogicValue(cbWantOutCardData[j]) < 15
								&& cbCardType != Constants.CT_SINGLE_LINE && cbCardType != Constants.CT_DOUBLE_LINE)
							return Constants.MAX_COUNT + 5; // 不拆炸弹

						else if (GetCardValue(cbBombCard[i]) == GetCardValue(cbWantOutCardData[j])
								&& GetCardLogicValue(cbWantOutCardData[j]) < 15
								&& (cbCardType == Constants.CT_SINGLE_LINE || cbCardType == Constants.CT_DOUBLE_LINE))
							cbMinSingleCardCount += 2; // 不拆炸弹
					}

				// 多个炸弹判断
				if (cbCardType == Constants.CT_SINGLE_LINE) {
					int cbBombCount = 0;

					for (int i = GetCardColor(cbBombCard[0]) == 4 ? 2 : 0; i < cbBombCardCount; i += 4)
						for (int j = 0; j < cbWantOutCardCount; ++j)
							if (GetCardValue(cbBombCard[i]) == GetCardValue(cbWantOutCardData[j]))
								++cbBombCount;

					if (cbBombCount >= 2)
						return Constants.MAX_COUNT; // 不拆炸弹

					// 三条个数
					tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();
					AnalysebCardData(cbHandCardData, cbHandCardCount, AnalyseResult);

					int cbThreeCount = 0;

					for (int i = 0; i < AnalyseResult.cbThreeCount; ++i)
						for (int j = 0; j < cbWantOutCardCount; ++j)
							if (GetCardValue(cbWantOutCardData[j]) == GetCardValue(
									AnalyseResult.cbThreeCardData[3 * i]))
								++cbThreeCount;

					if (cbThreeCount + cbBombCount >= 2)
						return Constants.MAX_COUNT + 5;

				}
			}
		}

		return cbMinSingleCardCount;
	}

	private int RunFun(int pTmpGetAllCardFun, int[] cbTmpCardData, int cbTmpCardCount, int[] cbGetCardData,int cbGetCardCount) {
//		int GetAllCardFunArray[] = new int[4];
//		GetAllCardFunArray[0] = GetAllBomCard; // 炸弹函数
//		GetAllCardFunArray[1] = GetAllLineCard; // 顺子函数
//		GetAllCardFunArray[2] = GetAllThreeCard; // 三条函数
//		GetAllCardFunArray[3] = GetAllDoubleCard; // 对子函数
		if (pTmpGetAllCardFun == GetAllBomCard) {
			return GetAllBomCard(cbTmpCardData, cbTmpCardCount, cbGetCardData, cbGetCardCount);
		}
		if (pTmpGetAllCardFun == GetAllLineCard) {
			return GetAllLineCard(cbTmpCardData, cbTmpCardCount, cbGetCardData, cbGetCardCount);
		}
		if (pTmpGetAllCardFun == GetAllThreeCard) {
			return GetAllThreeCard(cbTmpCardData, cbTmpCardCount, cbGetCardData, cbGetCardCount);
		}
		if (pTmpGetAllCardFun == GetAllDoubleCard) {
			return GetAllDoubleCard(cbTmpCardData, cbTmpCardCount, cbGetCardData, cbGetCardCount);
		}
		return 0;
	}

	// 设置扑克
	void SetUserCard(int wChairID, int cbCardData[], int cbCardCount) {
		Constants.CopyMemory(m_cbAllCardData[wChairID], cbCardData, cbCardCount);
		m_cbUserCardCount[wChairID] = cbCardCount;

		// 排列扑克
		SortCardList(m_cbAllCardData[wChairID], cbCardCount, Constants.ST_ORDER);
	}

	// 设置底牌
	void SetBackCard(int wChairID, int cbBackCardData[], int cbCardCount) {
		int cbTmpCount = m_cbUserCardCount[wChairID];
		Constants.CopyMemory(m_cbAllCardData[wChairID], cbTmpCount, cbBackCardData, cbCardCount);
		m_cbUserCardCount[wChairID] += cbCardCount;

		// 排列扑克
		SortCardList(m_cbAllCardData[wChairID], m_cbUserCardCount[wChairID], Constants.ST_ORDER);
	}

	// 设置庄家
	void SetBanker(int wBanker) {
		m_wBankerUser = wBanker;
		m_lBankerOutCardCount = 0;
	}

	// 叫牌扑克
	void SetLandScoreCardData(int cbCardData[], int cbCardCount) {

		Constants.CopyMemory(m_cbLandScoreCardData, cbCardData, cbCardCount);
		// 排列扑克
		SortCardList(m_cbLandScoreCardData, cbCardCount, Constants.ST_ORDER);
	}

	// 倒拉设置
	void SetCallScore(int wChairID, boolean bCallScore) {
		if (wChairID == Constants.INVALID_CHAIR) {
			for (int wIndex = 0; wIndex < Constants.DDZ_PLAYER; ++wIndex)
				m_bCallScore[wIndex] = bCallScore;
		} else
			m_bCallScore[wChairID] = bCallScore;
	}

	// 删除扑克
	void RemoveUserCardData(int wChairID, int cbRemoveCardData[], int cbRemoveCardCount) {
		boolean bSuccess = RemoveCard(cbRemoveCardData, cbRemoveCardCount, m_cbAllCardData[wChairID],
				m_cbUserCardCount[wChairID]);
		// ASSERT(bSuccess);
		m_cbUserCardCount[wChairID] -= cbRemoveCardCount;
		if (!bSuccess) {
			System.out.println("xxx");
		}
	}

	// 地主出牌（先出牌）
	void BankerOutCard(int cbHandCardData[], int cbHandCardCount, tagOutCardResult_Server OutCardResult) {
		// 零下标没用
		tagOutCardTypeResult_Server CardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
		tagOutCardTypeResult_Server.init(CardTypeResult);
		int cbLineCard[] = new int[Constants.MAX_COUNT];
		int cbThreeLineCard[] = new int[Constants.MAX_COUNT];
		int cbDoubleLineCard[] = new int[Constants.MAX_COUNT];
		int cbLineCardCount = 0;
		int cbThreeLineCardCount = 0;
		int cbDoubleLineCount = 0;
		cbLineCardCount = GetAllLineCard(cbHandCardData, cbHandCardCount, cbLineCard, cbLineCardCount);
		cbThreeLineCardCount = GetAllThreeCard(cbHandCardData, cbHandCardCount, cbThreeLineCard, cbThreeLineCardCount);
		cbDoubleLineCount = GetAllDoubleCard(cbHandCardData, cbHandCardCount, cbDoubleLineCard, cbDoubleLineCount);

		int wUndersideOfBanker = (m_wBankerUser + 1) % Constants.DDZ_PLAYER; // 地主下家
		int wUpsideOfBanker = (wUndersideOfBanker + 1) % Constants.DDZ_PLAYER; // 地主上家

		// 判断可否出完
		int cbSingleCardCount = Constants.MAX_COUNT + Constants.CT_MISSILE_CARD;
		boolean bFindBestCard = false;
		AnalyseOutCardType(cbHandCardData, cbHandCardCount, CardTypeResult);
		for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType)
			if (CardTypeResult[cbCardType].cbCardTypeCount > 0) {
				for (int lIndex = 0; lIndex < CardTypeResult[cbCardType].cbCardTypeCount; ++lIndex) {
					if (TestOutAllCard(m_wBankerUser, CardTypeResult[cbCardType].cbCardData[lIndex],
							CardTypeResult[cbCardType].cbEachHandCardCount[lIndex], true)) {
						// 计算单牌
						int cbTmpSingleCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
								CardTypeResult[cbCardType].cbCardData[lIndex],
								CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);

						// 结果判断
						if (cbTmpSingleCount >= Constants.MAX_COUNT)
							continue;

						// 炸弹优先级排后
						int cbBombCardType = GetCardType(CardTypeResult[cbCardType].cbCardData[lIndex],
								CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);
						if (cbBombCardType == Constants.CT_BOMB_CARD)
							cbTmpSingleCount += 4;
						else if (cbBombCardType == Constants.CT_MISSILE_CARD)
							cbTmpSingleCount += 5;
						else if (15 == GetCardLogicValue(CardTypeResult[cbCardType].cbCardData[lIndex][0]))
							cbTmpSingleCount += 2;
						else if (15 < GetCardLogicValue(CardTypeResult[cbCardType].cbCardData[lIndex][0]))
							cbTmpSingleCount += 3;

						//// 改变权值
						// if (cbBombCardType != CT_ERROR) cbTmpSingleCount +=
						//// cbBombCardType ;

						if (cbTmpSingleCount <= cbSingleCardCount) {
							// 设置变量
							OutCardResult.cbCardCount = CardTypeResult[cbCardType].cbEachHandCardCount[lIndex];
							Constants.CopyMemory(OutCardResult.cbResultCard,
									CardTypeResult[cbCardType].cbCardData[lIndex],
									CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);
							cbSingleCardCount = cbTmpSingleCount;
							bFindBestCard = true;
						}

					}
				}
			}
		// 直接返回
		if (bFindBestCard)
			return;

		// 对王和两单
		if (cbHandCardCount == 4 && GetCardLogicValue(cbHandCardData[1]) == 16
				&& m_cbUserCardCount[wUndersideOfBanker] == 1
				&& GetCardLogicValue(cbHandCardData[2]) < GetCardLogicValue(m_cbAllCardData[wUndersideOfBanker][0])) {
			OutCardResult.cbCardCount = 1;
			OutCardResult.cbResultCard[0] = cbHandCardData[2];
			return;
		}

		// 四带牌型判断
		if (AnalyseFourCardType(cbHandCardData, cbHandCardCount, m_cbAllCardData[wUndersideOfBanker],
				m_cbUserCardCount[wUndersideOfBanker], OutCardResult)) {
			return;
		}

		// 对王和两单
		if (cbHandCardCount == 4 && GetCardLogicValue(cbHandCardData[1]) == 16
				&& m_cbUserCardCount[wUpsideOfBanker] == 1
				&& GetCardLogicValue(cbHandCardData[2]) < GetCardLogicValue(m_cbAllCardData[wUpsideOfBanker][0])) {
			OutCardResult.cbCardCount = 1;
			OutCardResult.cbResultCard[0] = cbHandCardData[2];
			return;
		}

		// 四带牌型判断
		if (AnalyseFourCardType(cbHandCardData, cbHandCardCount, m_cbAllCardData[wUpsideOfBanker],
				m_cbUserCardCount[wUpsideOfBanker], OutCardResult)) {
			return;
		}

		// 如果只剩顺牌和单只，则先出顺
		{
			if (cbLineCardCount + 1 == cbHandCardCount
					&& Constants.CT_SINGLE == GetCardType(cbLineCard, cbLineCardCount)) {
				OutCardResult.cbCardCount = cbLineCardCount;
				Constants.CopyMemory(OutCardResult.cbResultCard, cbLineCard, cbLineCardCount);
			} else if (cbThreeLineCardCount + 1 == cbHandCardCount
					&& Constants.CT_THREE_LINE == GetCardType(cbThreeLineCard, cbThreeLineCardCount)) {
				OutCardResult.cbCardCount = cbThreeLineCardCount;
				Constants.CopyMemory(OutCardResult.cbResultCard, cbThreeLineCard, cbThreeLineCardCount);
			} else if (cbDoubleLineCount + 1 == cbHandCardCount
					&& Constants.CT_DOUBLE_LINE == GetCardType(cbDoubleLineCard, cbDoubleLineCount)) {
				OutCardResult.cbCardCount = cbDoubleLineCount;
				Constants.CopyMemory(OutCardResult.cbResultCard, cbDoubleLineCard, cbDoubleLineCount);
			}
			// 双王炸弹和一手
			else if (cbHandCardCount > 2 && cbHandCardData[0] == 0x4f && cbHandCardData[1] == 0x4e
					&& Constants.CT_ERROR != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)
					&& GetCardType(cbHandCardData, 2, cbHandCardCount - 2) != Constants.CT_FOUR_LINE_TAKE_ONE
					&& GetCardType(cbHandCardData, 2, cbHandCardCount - 2) != Constants.CT_FOUR_LINE_TAKE_TWO) {
				OutCardResult.cbCardCount = 2;
				OutCardResult.cbResultCard[0] = 0x4f;
				OutCardResult.cbResultCard[1] = 0x4e;
			}

			if (OutCardResult.cbCardCount > 0) {
				return;
			}
		}

		// 对王加一只
		if (cbHandCardCount == 3 && GetCardColor(cbHandCardData[0]) == 0x40
				&& GetCardColor(cbHandCardData[1]) == 0x40) {
			OutCardResult.cbCardCount = 2;
			OutCardResult.cbResultCard[0] = 0x4f;
			OutCardResult.cbResultCard[1] = 0x4e;
			return;
		}
		// 对王
		else if (cbHandCardCount == 2 && GetCardColor(cbHandCardData[0]) == 0x40
				&& GetCardColor(cbHandCardData[1]) == 0x40) {
			OutCardResult.cbCardCount = 2;
			OutCardResult.cbResultCard[0] = 0x4f;
			OutCardResult.cbResultCard[1] = 0x4e;
			return;
		}
		// 只剩一手牌
		else if (Constants.CT_ERROR != GetCardType(cbHandCardData, cbHandCardCount)
				&& Constants.CT_FOUR_LINE_TAKE_ONE != GetCardType(cbHandCardData, cbHandCardCount)
				&& Constants.CT_FOUR_LINE_TAKE_TWO != GetCardType(cbHandCardData, cbHandCardCount)) {
			OutCardResult.cbCardCount = cbHandCardCount;
			Constants.CopyMemory(OutCardResult.cbResultCard, cbHandCardData, cbHandCardCount);
			return;
		}

		// 只剩一张和一手
		if (cbHandCardCount >= 2) {
			// 上家扑克
			tagOutCardTypeResult_Server UpsideCanOutCardType1[] = new tagOutCardTypeResult_Server[13];
			tagOutCardTypeResult_Server.init(UpsideCanOutCardType1);
			tagOutCardTypeResult_Server UpsideCanOutCardType2[] = new tagOutCardTypeResult_Server[13];
			tagOutCardTypeResult_Server.init(UpsideCanOutCardType2);
			// 下家扑克
			tagOutCardTypeResult_Server UndersideCanOutCardType1[] = new tagOutCardTypeResult_Server[13];
			tagOutCardTypeResult_Server.init(UndersideCanOutCardType1);
			tagOutCardTypeResult_Server UndersideCanOutCardType2[] = new tagOutCardTypeResult_Server[13];
			tagOutCardTypeResult_Server.init(UndersideCanOutCardType2);

			int cbFirstHandCardType = GetCardType(cbHandCardData, cbHandCardCount - 1);
			int cbSecondHandCardType = GetCardType(cbHandCardData, 1, cbHandCardCount - 1);

			// 是否有炸
			int cbAllBombCardData[] = new int[Constants.MAX_COUNT];
			int cbAllBombCount = 0;
			cbAllBombCount = GetAllBomCard(cbHandCardData, cbHandCardCount, cbAllBombCardData, cbAllBombCount);

			// 没有炸弹
			if (cbAllBombCount <= 0 && cbFirstHandCardType != Constants.CT_THREE_LINE_TAKE_ONE
					&& cbFirstHandCardType != Constants.CT_THREE_LINE_TAKE_TWO) {
				if (Constants.CT_ERROR != cbFirstHandCardType && cbFirstHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbFirstHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO) {
					AnalyseOutCardType(m_cbAllCardData[wUpsideOfBanker], m_cbUserCardCount[wUpsideOfBanker],
							cbHandCardData, cbHandCardCount - 1, UpsideCanOutCardType1);
					AnalyseOutCardType(m_cbAllCardData[wUndersideOfBanker], m_cbUserCardCount[wUndersideOfBanker],
							cbHandCardData, cbHandCardCount - 1, UndersideCanOutCardType1);
				}
				if (Constants.CT_ERROR != cbSecondHandCardType
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO) {
					AnalyseOutCardType(m_cbAllCardData[wUpsideOfBanker], m_cbUserCardCount[wUpsideOfBanker],
							cbHandCardData, 1, cbHandCardCount - 1, UpsideCanOutCardType2);
					AnalyseOutCardType(m_cbAllCardData[wUndersideOfBanker], m_cbUserCardCount[wUndersideOfBanker],
							cbHandCardData, 1, cbHandCardCount - 1, UndersideCanOutCardType2);
				}

				if (cbSecondHandCardType != Constants.CT_ERROR
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO
						&& UpsideCanOutCardType2[cbSecondHandCardType].cbCardTypeCount == 0
						&& UndersideCanOutCardType2[cbSecondHandCardType].cbCardTypeCount == 0
						&& UpsideCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0
						&& UndersideCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0) {
					OutCardResult.cbCardCount = cbHandCardCount - 1;
					Constants.CopyMemory(OutCardResult.cbResultCard, 0, cbHandCardData, 1, cbHandCardCount - 1);
					return;
				}

				if (cbFirstHandCardType != Constants.CT_ERROR && cbFirstHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbFirstHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO
						&& UpsideCanOutCardType1[cbFirstHandCardType].cbCardTypeCount == 0
						&& UndersideCanOutCardType1[cbFirstHandCardType].cbCardTypeCount == 0
						&& UpsideCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0
						&& UndersideCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0) {
					OutCardResult.cbCardCount = cbHandCardCount - 1;
					Constants.CopyMemory(OutCardResult.cbResultCard, cbHandCardData, cbHandCardCount - 1);
					return;
				}

				if (GetCardLogicValue(cbHandCardData[0]) >= GetCardLogicValue(m_cbAllCardData[wUpsideOfBanker][0])
						&& GetCardLogicValue(cbHandCardData[0]) >= GetCardLogicValue(
								m_cbAllCardData[wUndersideOfBanker][0])
						&& Constants.CT_ERROR != cbSecondHandCardType
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO
						&& UpsideCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0
						&& UndersideCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0) {
					OutCardResult.cbCardCount = 1;
					OutCardResult.cbResultCard[0] = cbHandCardData[0];
					return;
				}

				if (Constants.CT_ERROR != cbSecondHandCardType
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO
						&& UpsideCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0
						&& UndersideCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0) {
					OutCardResult.cbCardCount = cbHandCardCount - 1;
					Constants.CopyMemory(OutCardResult.cbResultCard, 0, cbHandCardData, 1, cbHandCardCount - 1);
					return;
				}
			}
			// 还有炸弹
			else {
				// 除去炸后的牌
				int cbRemainCard[] = new int[Constants.MAX_COUNT];
				int cbRemainCount = 0;
				Constants.CopyMemory(cbRemainCard, cbHandCardData, cbHandCardCount);
				cbRemainCount = cbHandCardCount;
				RemoveCard(cbAllBombCardData, cbAllBombCount, cbRemainCard, cbRemainCount);
				cbRemainCount -= cbAllBombCount;
				if (GetCardType(cbRemainCard, cbRemainCount) != Constants.CT_ERROR) {
					OutCardResult.cbCardCount = cbRemainCount;
					Constants.CopyMemory(OutCardResult.cbResultCard, cbRemainCard, cbRemainCount);
					return;
				}
			}
		}

		{
			{
				// 分析扑克
				tagOutCardTypeResult_Server MeOutCardTypeResult[] = new tagOutCardTypeResult_Server[13];
				tagOutCardTypeResult_Server.init(MeOutCardTypeResult);
				AnalyseOutCardType(cbHandCardData, cbHandCardCount, MeOutCardTypeResult);

				// 计算单牌
				int cbMinSingleCardCount[] = new int[4];
				cbMinSingleCardCount[0] = Constants.MAX_COUNT;
				cbMinSingleCardCount[1] = Constants.MAX_COUNT;
				cbMinSingleCardCount[2] = Constants.MAX_COUNT;
				cbMinSingleCardCount[3] = Constants.MAX_COUNT;
				int cbIndex[] = { 0, 0, 0, 0 };
				int cbOutcardType[] = { Constants.CT_ERROR, Constants.CT_ERROR, Constants.CT_ERROR,
						Constants.CT_ERROR };
				int cbMinValue = Constants.MAX_COUNT;
				int cbMinSingleCountInFour = Constants.MAX_COUNT;
				int cbMinCardType = Constants.CT_ERROR;
				int cbMinIndex = 0;

				// 除炸弹外的牌
				for (int cbCardType = Constants.CT_DOUBLE; cbCardType < Constants.CT_BOMB_CARD; ++cbCardType) {

					tagOutCardTypeResult_Server tmpCardResult = MeOutCardTypeResult[cbCardType];

					// 相同牌型，相同长度，单连，对连等相同牌型可能长度不一样
					int cbThisHandCardCount = Constants.MAX_COUNT;

					// 上家扑克
					tagOutCardTypeResult_Server UpsideOutCardTypeResult[] = new tagOutCardTypeResult_Server[13];
					tagOutCardTypeResult_Server.init(UpsideOutCardTypeResult);
					// 下家扑克
					tagOutCardTypeResult_Server UndersideOutCardTypeResult[] = new tagOutCardTypeResult_Server[13];
					tagOutCardTypeResult_Server.init(UndersideOutCardTypeResult);
					for (int i = 0; i < tmpCardResult.cbCardTypeCount; ++i) {
						// 拆三条判断
						if (cbCardType == Constants.CT_DOUBLE) {
							tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();
							AnalysebCardData(cbHandCardData, cbHandCardCount, AnalyseResult);
							if (AnalyseResult.cbSignedCount + AnalyseResult.cbThreeCount * 3 == cbHandCardCount) {
								boolean bContinue = false;
								for (int cbThreeIndex = 0; cbThreeIndex < AnalyseResult.cbThreeCount; ++cbThreeIndex)
									if (GetCardValue(tmpCardResult.cbCardData[i][0]) == GetCardValue(
											AnalyseResult.cbThreeCardData[3 * cbThreeIndex])) {
										bContinue = true;
										break;
									}
								if (bContinue)
									continue;
							}
						}

						int cbTmpCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
								tmpCardResult.cbCardData[i], tmpCardResult.cbEachHandCardCount[i]);

						// 重新分析
						if (tmpCardResult.cbEachHandCardCount[i] != cbThisHandCardCount) {
							cbThisHandCardCount = tmpCardResult.cbEachHandCardCount[i];
							AnalyseOutCardType(m_cbAllCardData[wUpsideOfBanker], m_cbUserCardCount[wUpsideOfBanker],
									tmpCardResult.cbCardData[i], tmpCardResult.cbEachHandCardCount[i],
									UpsideOutCardTypeResult);
							AnalyseOutCardType(m_cbAllCardData[wUndersideOfBanker],
									m_cbUserCardCount[wUndersideOfBanker], tmpCardResult.cbCardData[i],
									tmpCardResult.cbEachHandCardCount[i], UndersideOutCardTypeResult);
						}
						int cbMaxValue = 0;
						int Index = 0;

						// 针对顺子，三条的大牌
						int cbCurrentCardType = GetCardType(tmpCardResult.cbCardData[i], cbThisHandCardCount);
						if (cbThisHandCardCount != cbHandCardCount && cbCurrentCardType >= Constants.CT_SINGLE_LINE
								&& cbCurrentCardType <= Constants.CT_THREE_LINE_TAKE_TWO
								&& (GetCardLogicValue(
										tmpCardResult.cbCardData[i][cbThisHandCardCount - 1]) > GetCardLogicValue(
												cbHandCardData[cbHandCardCount - 2])
										|| GetCardLogicValue(tmpCardResult.cbCardData[i][0]) >= 11)) {
							int cbRemainCardData[] = new int[Constants.MAX_COUNT], cbRemainCardCount;
							Constants.CopyMemory(cbRemainCardData, cbHandCardData, cbHandCardCount);
							cbRemainCardCount = cbHandCardCount;

							// 移除扑克
							RemoveCard(tmpCardResult.cbCardData[i], cbThisHandCardCount, cbRemainCardData,
									cbRemainCardCount);
							cbRemainCardCount -= cbThisHandCardCount;

							// 最大扑克
							int cbCurrentLargestLogicCard = GetCardLogicValue(tmpCardResult.cbCardData[i][0]);

							if (GetCardType(cbRemainCardData, cbRemainCardCount) == Constants.CT_ERROR
									&& (cbCurrentCardType >= Constants.CT_THREE_LINE_TAKE_ONE
											&& cbCurrentCardType <= Constants.CT_THREE_LINE_TAKE_TWO
											&& cbCurrentLargestLogicCard >= 11 && cbThisHandCardCount <= 5
											|| cbCurrentCardType == Constants.CT_SINGLE_LINE && cbThisHandCardCount <= 6
													&& cbCurrentLargestLogicCard >= 12
											|| cbCurrentCardType >= Constants.CT_DOUBLE_LINE
													&& cbCurrentCardType <= Constants.CT_THREE_LINE
													&& cbCurrentLargestLogicCard >= 12 && cbThisHandCardCount <= 8)) {
								// 暂时不出
								if (cbCurrentCardType >= Constants.CT_SINGLE_LINE
										&& cbCurrentCardType <= Constants.CT_THREE_LINE
										&& GetCardLogicValue(tmpCardResult.cbCardData[i][cbThisHandCardCount
												- 1]) > GetCardLogicValue(cbHandCardData[cbHandCardCount - 3]))
									continue;

								if (cbCurrentCardType >= Constants.CT_THREE_LINE_TAKE_ONE
										&& cbCurrentCardType <= Constants.CT_THREE_LINE_TAKE_TWO
										&& GetCardLogicValue(tmpCardResult.cbCardData[i][0]) > GetCardLogicValue(
												cbHandCardData[cbHandCardCount - 3]))
									continue;
							}
						}

						// 针对大对（不可先出）
						if (cbCardType == Constants.CT_DOUBLE  && GetCardLogicValue(tmpCardResult.cbCardData[i][0]) >= 11) {
							int cbAllSingleCardData[] = new int[Constants.MAX_COUNT], cbAllSingleCount;
							cbAllSingleCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0,
									cbAllSingleCardData);
							if (cbAllSingleCount <= cbAllSingleCardData.length - 1 &&  cbAllSingleCount >= 2 && GetCardLogicValue(cbAllSingleCardData[cbAllSingleCount - 2]) < 10)
								continue;
						}

						// 敌方可以压住牌
						if (UpsideOutCardTypeResult[cbCardType].cbCardTypeCount > 0
								|| UndersideOutCardTypeResult[cbCardType].cbCardTypeCount > 0) {
							// 上家跑掉
							if (UpsideOutCardTypeResult[cbCardType].cbEachHandCardCount[0] > 0
									&& m_cbUserCardCount[wUpsideOfBanker] <= UpsideOutCardTypeResult[cbCardType].cbEachHandCardCount[0]
											+ 1)
								continue;

							// 下家跑掉
							if (UndersideOutCardTypeResult[cbCardType].cbEachHandCardCount[0] > 0
									&& m_cbUserCardCount[wUndersideOfBanker] <= UndersideOutCardTypeResult[cbCardType].cbEachHandCardCount[0]
											+ 1)
								continue;

							// 自己不可以再拿回牌权
							// if(UpsideOutCardTypeResult[cbCardType].cbCardTypeCount
							// > 0 &&
							// GetCardLogicValue(tmpCardResult.cbCardData[0][0])
							// <
							// GetCardLogicValue(UpsideOutCardTypeResult[cbCardType].cbCardData[0][0])
							// ||
							// UpsideOutCardTypeResult[cbCardType].cbCardTypeCount
							// > 0 &&
							// GetCardLogicValue(tmpCardResult.cbCardData[0][0])
							// <
							// GetCardLogicValue(UpsideOutCardTypeResult[cbCardType].cbCardData[0][0]))
							// continue ;
						}
						// 是否有大牌
						if (tmpCardResult.cbEachHandCardCount[i] != cbHandCardCount) {
							boolean bHaveLargeCard = false;
							for (int j = 0; j < tmpCardResult.cbEachHandCardCount[i]; ++j) {
								if (GetCardLogicValue(tmpCardResult.cbCardData[i][j]) >= 15)
									bHaveLargeCard = true;
								if (cbCardType != Constants.CT_SINGLE_LINE && cbCardType != Constants.CT_DOUBLE_LINE
										&& GetCardLogicValue(tmpCardResult.cbCardData[i][0]) == 14)
									bHaveLargeCard = true;
							}

							if (bHaveLargeCard)
								continue;
						}

						// 搜索cbMinSingleCardCount[4]的最大值
						for (int j = 0; j < 4; ++j) {
							if (cbMinSingleCardCount[j] >= cbTmpCount) {
								cbMinSingleCardCount[j] = cbTmpCount;
								cbIndex[j] = i;
								cbOutcardType[j] = cbCardType;
								break;
							}
						}

						// 保存最小值
						if (cbMinSingleCountInFour >= cbTmpCount) {
							// 最小牌型
							cbMinCardType = cbCardType;
							// 最小牌型中的最小单牌
							cbMinSingleCountInFour = cbTmpCount;
							// 最小牌型中的最小牌
							cbMinIndex = i;
						}
					}
				}

				if (cbMinSingleCountInFour >= AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0) + 3
						&& (m_cbUserCardCount[wUndersideOfBanker] >= 4 && m_cbUserCardCount[wUpsideOfBanker] >= 4))
					cbMinSingleCountInFour = Constants.MAX_COUNT;

				if (cbMinSingleCountInFour != Constants.MAX_COUNT) {
					int Index = cbMinIndex;

					// 选择最小牌
					for (int i = 0; i < 4; ++i) {
						if (cbOutcardType[i] == cbMinCardType && cbMinSingleCardCount[i] <= cbMinSingleCountInFour
								&& GetCardLogicValue(
										MeOutCardTypeResult[cbMinCardType].cbCardData[cbIndex[i]][0]) < GetCardLogicValue(
												MeOutCardTypeResult[cbMinCardType].cbCardData[Index][0]))
							Index = cbIndex[i];
					}

					// 对王加一只
					if (cbHandCardCount == 3 && GetCardColor(cbHandCardData[0]) == 0x40
							&& GetCardColor(cbHandCardData[1]) == 0x40) {
						OutCardResult.cbCardCount = 2;
						OutCardResult.cbResultCard[0] = 0x4f;
						OutCardResult.cbResultCard[1] = 0x4e;
						return;
					}
					// 对王
					else if (cbHandCardCount == 2 && GetCardColor(cbHandCardData[0]) == 0x40
							&& GetCardColor(cbHandCardData[1]) == 0x40) {
						OutCardResult.cbCardCount = 2;
						OutCardResult.cbResultCard[0] = 0x4f;
						OutCardResult.cbResultCard[1] = 0x4e;
						return;
					} else {
						// 设置变量
						OutCardResult.cbCardCount = MeOutCardTypeResult[cbMinCardType].cbEachHandCardCount[Index];
						Constants.CopyMemory(OutCardResult.cbResultCard,
								MeOutCardTypeResult[cbMinCardType].cbCardData[Index],
								MeOutCardTypeResult[cbMinCardType].cbEachHandCardCount[Index]);
						return;
					}
				}

				// 还没有找到适合的牌则从大出到小
				if (OutCardResult.cbCardCount <= 0
						&& (m_cbUserCardCount[wUndersideOfBanker] == 1 || m_cbUserCardCount[wUpsideOfBanker] == 1)) {
					// 只有一张牌时不能放走
					if (MeOutCardTypeResult[Constants.CT_SINGLE].cbCardTypeCount > 0) {
						int Index = Constants.MAX_COUNT;
						for (int i = 0; i < MeOutCardTypeResult[Constants.CT_SINGLE].cbCardTypeCount; ++i) {
							if ((m_cbUserCardCount[wUndersideOfBanker] == 1 && GetCardLogicValue(
									MeOutCardTypeResult[Constants.CT_SINGLE].cbCardData[i][0]) >= GetCardLogicValue(
											m_cbAllCardData[wUndersideOfBanker][0]))
									|| (m_cbUserCardCount[wUpsideOfBanker] == 1 && GetCardLogicValue(
											MeOutCardTypeResult[Constants.CT_SINGLE].cbCardData[i][0]) >= GetCardLogicValue(
													m_cbAllCardData[wUpsideOfBanker][0]))) {
								Index = i;
							} else
								break;
						}

						if (Constants.MAX_COUNT != Index) {
							OutCardResult.cbCardCount = MeOutCardTypeResult[Constants.CT_SINGLE].cbEachHandCardCount[Index];
							Constants.CopyMemory(OutCardResult.cbResultCard,
									MeOutCardTypeResult[Constants.CT_SINGLE].cbCardData[Index],
									OutCardResult.cbCardCount);
							return;
						}
					}
				}
			}
		}
		int cbFirstCard = 0;
		// 过滤王和2
		for (int i = 0; i < cbHandCardCount; ++i)
			if (GetCardLogicValue(cbHandCardData[i]) < 15) {
				cbFirstCard = i;
				break;
			}

		if (cbFirstCard < cbHandCardCount - 1)
			AnalyseOutCardType(cbHandCardData, cbFirstCard, cbHandCardCount - cbFirstCard, CardTypeResult);
		else
			AnalyseOutCardType(cbHandCardData, cbHandCardCount, CardTypeResult);

		// 计算单牌
		int cbMinSingleCardCount[] = new int[4];
		cbMinSingleCardCount[0] = Constants.MAX_COUNT;
		cbMinSingleCardCount[1] = Constants.MAX_COUNT;
		cbMinSingleCardCount[2] = Constants.MAX_COUNT;
		cbMinSingleCardCount[3] = Constants.MAX_COUNT;
		int cbIndex[] = { 0, 0, 0, 0 };
		int cbOutcardType[] = { Constants.CT_ERROR, Constants.CT_ERROR, Constants.CT_ERROR, Constants.CT_ERROR };
		int cbMinValue = Constants.MAX_COUNT;
		int cbMinSingleCountInFour = Constants.MAX_COUNT;
		int cbMinCardType = Constants.CT_ERROR;
		int cbMinIndex = 0;

		// 除炸弹外的牌
		for (int cbCardType = Constants.CT_SINGLE; cbCardType < Constants.CT_BOMB_CARD; ++cbCardType) {
			tagOutCardTypeResult_Server tmpCardResult = CardTypeResult[cbCardType];
			for (int i = 0; i < tmpCardResult.cbCardTypeCount; ++i) {
				// 闲家可以走掉
				if (CompareCard(tmpCardResult.cbCardData[i], m_cbAllCardData[wUndersideOfBanker],
						tmpCardResult.cbEachHandCardCount[i], m_cbUserCardCount[wUndersideOfBanker])
						|| CompareCard(tmpCardResult.cbCardData[i], m_cbAllCardData[wUpsideOfBanker],
								tmpCardResult.cbEachHandCardCount[i], m_cbUserCardCount[wUpsideOfBanker]))
					continue;

				// 针对顺子，三条的大牌
				if (tmpCardResult.cbEachHandCardCount[i] != cbHandCardCount && cbCardType >= Constants.CT_SINGLE_LINE
						&& cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO
						&& (GetCardLogicValue(tmpCardResult.cbCardData[i][tmpCardResult.cbEachHandCardCount[i]
								- 1]) > GetCardLogicValue(cbHandCardData[cbHandCardCount - 2])
								|| GetCardLogicValue(tmpCardResult.cbCardData[i][0]) >= 11)) {
					int cbRemainCardData[] = new int[Constants.MAX_COUNT], cbRemainCardCount;
					Constants.CopyMemory(cbRemainCardData, cbHandCardData, cbHandCardCount);
					cbRemainCardCount = cbHandCardCount;

					// 移除扑克
					RemoveCard(tmpCardResult.cbCardData[i], tmpCardResult.cbEachHandCardCount[i], cbRemainCardData,
							cbRemainCardCount);
					cbRemainCardCount -= tmpCardResult.cbEachHandCardCount[i];

					// 最大扑克
					int cbCurrentLargestLogicCard = GetCardLogicValue(tmpCardResult.cbCardData[i][0]);

					if (GetCardType(cbRemainCardData, cbRemainCardCount) == Constants.CT_ERROR
							&& (cbCardType >= Constants.CT_THREE_LINE_TAKE_ONE
									&& cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO && cbCurrentLargestLogicCard >= 11
									&& tmpCardResult.cbEachHandCardCount[i] <= 5
									|| cbCardType == Constants.CT_SINGLE_LINE
											&& tmpCardResult.cbEachHandCardCount[i] <= 6
											&& cbCurrentLargestLogicCard >= 12
									|| cbCardType >= Constants.CT_DOUBLE_LINE && cbCardType <= Constants.CT_THREE_LINE
											&& cbCurrentLargestLogicCard >= 12
											&& tmpCardResult.cbEachHandCardCount[i] <= 8)) {
						// 暂时不出
						if (cbCardType >= Constants.CT_SINGLE_LINE && cbCardType <= Constants.CT_THREE_LINE
								&& GetCardLogicValue(tmpCardResult.cbCardData[i][tmpCardResult.cbEachHandCardCount[i]
										- 1]) > GetCardLogicValue(cbHandCardData[cbHandCardCount - 3]))
							continue;

						if (cbCardType >= Constants.CT_THREE_LINE_TAKE_ONE
								&& cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO
								&& GetCardLogicValue(tmpCardResult.cbCardData[i][0]) > GetCardLogicValue(
										cbHandCardData[cbHandCardCount - 3]))
							continue;
					}
				}

				int cbTmpCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, tmpCardResult.cbCardData[i],
						tmpCardResult.cbEachHandCardCount[i]);

				int cbMaxValue = 0;
				int Index = 0;

				// 搜索cbMinSingleCardCount[4]的最大值
				for (int j = 0; j < 4; ++j) {
					if (cbMinSingleCardCount[j] >= cbTmpCount) {
						cbMinSingleCardCount[j] = cbTmpCount;
						cbIndex[j] = i;
						cbOutcardType[j] = cbCardType;
						break;
					}
				}

				// 保存最小值
				if (cbMinSingleCountInFour >= cbTmpCount) {
					// 最小牌型
					cbMinCardType = cbCardType;
					// 最小牌型中的最小单牌
					cbMinSingleCountInFour = cbTmpCount;
					// 最小牌型中的最小牌
					cbMinIndex = i;
				}
			}
		}

		if (cbMinSingleCountInFour != Constants.MAX_COUNT) {
			int Index = cbMinIndex;

			// 选择最小牌
			for (int i = 0; i < 4; ++i) {
				if (cbOutcardType[i] == cbMinCardType && cbMinSingleCardCount[i] <= cbMinSingleCountInFour
						&& GetCardLogicValue(
								CardTypeResult[cbMinCardType].cbCardData[cbIndex[i]][0]) < GetCardLogicValue(
										CardTypeResult[cbMinCardType].cbCardData[Index][0]))
					Index = cbIndex[i];
			}

			// 对王加一只
			if (cbHandCardCount == 3 && GetCardColor(cbHandCardData[0]) == 0x40
					&& GetCardColor(cbHandCardData[1]) == 0x40) {
				OutCardResult.cbCardCount = 2;
				OutCardResult.cbResultCard[0] = 0x4f;
				OutCardResult.cbResultCard[1] = 0x4e;
				return;
			}
			// 对王
			else if (cbHandCardCount == 2 && GetCardColor(cbHandCardData[0]) == 0x40
					&& GetCardColor(cbHandCardData[1]) == 0x40) {
				OutCardResult.cbCardCount = 2;
				OutCardResult.cbResultCard[0] = 0x4f;
				OutCardResult.cbResultCard[1] = 0x4e;
				return;
			} else {
				// 设置变量
				OutCardResult.cbCardCount = CardTypeResult[cbMinCardType].cbEachHandCardCount[Index];
				Constants.CopyMemory(OutCardResult.cbResultCard, CardTypeResult[cbMinCardType].cbCardData[Index],
						CardTypeResult[cbMinCardType].cbEachHandCardCount[Index]);
				return;
			}
		}
		// 如果只剩炸弹
		else if (CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount > 0) {
			// int Index=0 ;
			// int cbLogicCardValue = GetCardLogicValue(0x4F)+1 ;
			//// 最小炸弹
			// for(int i=0; i<CardTypeResult[CT_BOMB_CARD].cbCardTypeCount; ++i)
			// if(cbLogicCardValue>GetCardLogicValue(CardTypeResult[CT_BOMB_CARD].cbCardData[i][0]))
			// {
			// cbLogicCardValue =
			// GetCardLogicValue(CardTypeResult[CT_BOMB_CARD].cbCardData[i][0])
			// ;
			// Index = i ;
			// }

			// //设置变量
			// OutCardResult.cbCardCount=CardTypeResult[CT_BOMB_CARD].cbEachHandCardCount[Index];
			// CopyMemory(OutCardResult.cbResultCard,CardTypeResult[CT_BOMB_CARD].cbCardData[Index],CardTypeResult[CT_BOMB_CARD].cbEachHandCardCount[Index]*sizeof(int));

			// return ;
		}

		int cbAllSingleCardData[] = new int[Constants.MAX_COUNT], cbAllSingleCardCount;
		cbAllSingleCardCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0, cbAllSingleCardData);

		if (cbAllSingleCardCount > 0) {
			// 如果都没有搜索到就出最小的一张
			if ((1 == m_cbUserCardCount[wUndersideOfBanker] || 1 == m_cbUserCardCount[wUpsideOfBanker])
					&& cbAllSingleCardCount >= 2) {
				OutCardResult.cbCardCount = 1;
				OutCardResult.cbResultCard[0] = cbAllSingleCardData[cbAllSingleCardCount - 2];
			} else {
				OutCardResult.cbCardCount = 1;
				OutCardResult.cbResultCard[0] = cbAllSingleCardData[cbAllSingleCardCount - 1];
			}
			return;
		}

		// 如果都没有搜索到就出最小的一张
		OutCardResult.cbCardCount = 1;
		OutCardResult.cbResultCard[0] = cbHandCardData[cbHandCardCount - 1];

		return;
	}

	void BankerOutCard(int cbHandCardData[], int cbHandCardCount, int wOutCardUser, int cbTurnCardData[],
			int cbTurnCardCount, tagOutCardResult_Server OutCardResult) {
		// 初始变量

		// 零下标没用
		tagOutCardTypeResult_Server CardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
		tagOutCardTypeResult_Server.init(CardTypeResult);
		// 出牌类型
		int cbOutCardType = GetCardType(cbTurnCardData, cbTurnCardCount);
		AnalyseOutCardType(cbHandCardData, cbHandCardCount, cbTurnCardData, cbTurnCardCount, CardTypeResult);

		int wUndersideUser = (m_wBankerUser + 1) % Constants.DDZ_PLAYER;
		int wUpsideUser = (wUndersideUser + 1) % Constants.DDZ_PLAYER;

		// 只剩炸弹
		if (cbHandCardCount == CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[0]
				&& (cbOutCardType < Constants.CT_BOMB_CARD || GetCardLogicValue(
						CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[0][0]) > GetCardLogicValue(
								cbTurnCardData[0]))) {
			OutCardResult.cbCardCount = CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[0];
			Constants.CopyMemory(OutCardResult.cbResultCard, CardTypeResult[Constants.CT_BOMB_CARD].cbCardData,
					OutCardResult.cbCardCount);

			return;
		}
		// 双王炸弹和一手
		else if (cbHandCardCount > 2 && cbHandCardData[0] == 0x4f && cbHandCardData[1] == 0x4e
				&& Constants.CT_ERROR != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)
				&& Constants.CT_FOUR_LINE_TAKE_ONE != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)
				&& Constants.CT_FOUR_LINE_TAKE_TWO != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)) {
			OutCardResult.cbCardCount = 2;
			OutCardResult.cbResultCard[0] = 0x4f;
			OutCardResult.cbResultCard[1] = 0x4e;
			return;
		}

		// 炸弹和一手
		int cbRemainCard[] = new int[Constants.MAX_COUNT];
		int cbRemainCount = 0;
		int cbAllBombCard[] = new int[Constants.MAX_COUNT];
		int cbAllBombCount = 0;
		cbAllBombCount = GetAllBomCard(cbHandCardData, cbHandCardCount, cbAllBombCard, cbAllBombCount);

		// 出炸判断
		if (cbAllBombCount > 0) {
			// 剩余扑克
			Constants.CopyMemory(cbRemainCard, cbHandCardData, cbHandCardCount);
			cbRemainCount = cbHandCardCount;
			RemoveCard(cbAllBombCard, cbAllBombCount, cbRemainCard, cbRemainCount);
			cbRemainCount -= cbAllBombCount;

			if (Constants.CT_ERROR != GetCardType(cbRemainCard, cbRemainCount) || (2 == cbRemainCount
					&& GetCardLogicValue(cbRemainCard[0]) > GetCardLogicValue(m_cbAllCardData[wUndersideUser][0])
					&& GetCardLogicValue(cbRemainCard[0]) > GetCardLogicValue(m_cbAllCardData[wUpsideUser][0]))) {
				if ((cbOutCardType < Constants.CT_BOMB_CARD
						|| GetCardLogicValue(cbAllBombCard[0]) > GetCardLogicValue(cbTurnCardData[0]))
						&& (CardTypeResult[cbOutCardType].cbCardTypeCount <= 0
								|| Constants.CT_ERROR != GetCardType(cbRemainCard, cbRemainCount))) {
					// 双王炸弹
					if (GetCardColor(cbAllBombCard[0]) == 0x40) {
						OutCardResult.cbCardCount = 2;
						OutCardResult.cbResultCard[0] = 0x4f;
						OutCardResult.cbResultCard[1] = 0x4e;
						return;
					} else {
						// 分析闲家牌
						int cbUnderSideBankerAllBombCard[] = new int[Constants.MAX_COUNT],
								cbUnderSideBankerAllBombCardCount = 0;
						cbUnderSideBankerAllBombCardCount = GetAllBomCard(m_cbAllCardData[wUndersideUser],
								m_cbUserCardCount[wUndersideUser], cbUnderSideBankerAllBombCard,
								cbUnderSideBankerAllBombCardCount);

						int cbUpSideBankerAllBombCard[] = new int[Constants.MAX_COUNT],
								cbUpSideBankerAllBombCardCount = 0;
						cbUpSideBankerAllBombCardCount = GetAllBomCard(m_cbAllCardData[wUpsideUser],
								m_cbUserCardCount[wUpsideUser], cbUpSideBankerAllBombCard,
								cbUpSideBankerAllBombCardCount);

						if (!CompareCard(cbTurnCardData, cbRemainCard, cbTurnCardCount, cbRemainCount)
								|| (cbUnderSideBankerAllBombCardCount <= 0 && cbUpSideBankerAllBombCardCount != 0)
								|| (GetCardLogicValue(cbAllBombCard[0]) > GetCardLogicValue(
										cbUnderSideBankerAllBombCard[0])
										&& GetCardLogicValue(cbAllBombCard[0]) > GetCardLogicValue(
												cbUpSideBankerAllBombCard[0]))) {
							OutCardResult.cbCardCount = 4;
							Constants.CopyMemory(OutCardResult.cbResultCard, cbAllBombCard, 4);
							return;
						}
					}
				}
			}
		}

		// 判断可否出完
		int cbSingleCardCount = Constants.MAX_COUNT + Constants.CT_MISSILE_CARD;
		boolean bFindBestCard = false;
		for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType)
			if (CardTypeResult[cbCardType].cbCardTypeCount > 0) {
				for (int lIndex = 0; lIndex < CardTypeResult[cbCardType].cbCardTypeCount; ++lIndex) {
					if (TestOutAllCard(m_wBankerUser, CardTypeResult[cbCardType].cbCardData[lIndex],
							CardTypeResult[cbCardType].cbEachHandCardCount[lIndex], false)) {
						// 计算单牌
						int cbTmpSingleCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
								CardTypeResult[cbCardType].cbCardData[lIndex],
								CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);

						// 结果判断
						if (cbTmpSingleCount >= Constants.MAX_COUNT)
							continue;

						// 炸弹优先级排后
						int cbBombCardType = GetCardType(CardTypeResult[cbCardType].cbCardData[lIndex],
								CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);
						if (cbBombCardType == Constants.CT_BOMB_CARD)
							cbTmpSingleCount += 4;
						else if (cbBombCardType == Constants.CT_MISSILE_CARD)
							cbTmpSingleCount += 5;

						//// 改变权值
						// if (cbBombCardType != CT_ERROR) cbTmpSingleCount +=
						//// cbBombCardType ;

						// 不出炸弹
						// int cbWantOutCardType =
						// GetCardType(CardTypeResult[cbCardType].cbCardData[lIndex],
						// CardTypeResult[cbCardType].cbEachHandCardCount[lIndex])
						// ;
						// if (CardTypeResult[cbOutCardType].cbCardTypeCount > 0
						// &&
						// cbOutCardType < CT_BOMB_CARD && cbWantOutCardType >=
						// CT_BOMB_CARD)
						// continue ;

						if (cbTmpSingleCount <= cbSingleCardCount) {
							// 设置变量
							OutCardResult.cbCardCount = CardTypeResult[cbCardType].cbEachHandCardCount[lIndex];
							Constants.CopyMemory(OutCardResult.cbResultCard,
									CardTypeResult[cbCardType].cbCardData[lIndex],
									CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);
							cbSingleCardCount = cbTmpSingleCount;
							bFindBestCard = true;
						}
					}
				}
			}
		// 直接返回
		if (bFindBestCard)
			return;

		// 取出四个最小单牌
		int cbMinSingleCardCount[] = new int[4];
		cbMinSingleCardCount[0] = Constants.MAX_COUNT;
		cbMinSingleCardCount[1] = Constants.MAX_COUNT;
		cbMinSingleCardCount[2] = Constants.MAX_COUNT;
		cbMinSingleCardCount[3] = Constants.MAX_COUNT;
		int cbIndex[] = { 0, 0, 0, 0 };
		int cbMinSingleCountInFour = Constants.MAX_COUNT;

		// 可出扑克（这里已经过滤掉炸弹了）
		tagOutCardTypeResult_Server CanOutCard = CardTypeResult[cbOutCardType];

		for (int i = 0; i < CanOutCard.cbCardTypeCount; ++i) {
			// 最小单牌
			int cbTmpCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, CanOutCard.cbCardData[i],
					CanOutCard.cbEachHandCardCount[i]);
			int cbMaxValue = 0;
			int Index = 0;

			// 搜索cbMinSingleCardCount[4]的最大值
			for (int j = 0; j < 4; ++j) {
				if (cbMinSingleCardCount[j] >= cbTmpCount) {
					cbMinSingleCardCount[j] = cbTmpCount;
					cbIndex[j] = i;
					break;
				}
			}

		}

		for (int i = 0; i < 4; ++i)
			if (cbMinSingleCountInFour > cbMinSingleCardCount[i])
				cbMinSingleCountInFour = cbMinSingleCardCount[i];

		// 原始单牌数
		int cbOriginSingleCardCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0);

		if (CanOutCard.cbCardTypeCount > 0 && cbMinSingleCountInFour < Constants.MAX_COUNT) {
			int cbMinLogicCardValue = GetCardLogicValue(0x4F) + 1;
			boolean bFindCard = false;
			int cbCanOutIndex = 0;
			for (int i = 0; i < 4; ++i) {
				int Index = cbIndex[i];

				if ((cbMinSingleCardCount[i] < cbOriginSingleCardCount + 3)
						&& (cbMinSingleCardCount[i] <= cbMinSingleCountInFour
								|| cbMinSingleCardCount[i] <= cbMinSingleCountInFour + 1
										&& CanOutCard.cbCardType >= Constants.CT_THREE_LINE_TAKE_ONE
										&& CanOutCard.cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO)
						&& cbMinLogicCardValue > GetCardLogicValue(CanOutCard.cbCardData[Index][0])) {
					// 针对大牌
					boolean bNoLargeCard = true;

					// 当出牌玩家手上牌数大于4，而且出的是小于K的牌而且不是出牌手上的最大牌时，不能出2去打
					if (m_cbUserCardCount[wOutCardUser] >= 4 && cbHandCardCount >= 5
							&& CanOutCard.cbEachHandCardCount[Index] >= 2
							&& GetCardLogicValue(CanOutCard.cbCardData[Index][0]) >= 15
							&& GetCardLogicValue(cbTurnCardData[0]) < 13
							&& (wOutCardUser == wUndersideUser
									&& GetCardLogicValue(cbTurnCardData[0]) < GetCardLogicValue(
											m_cbAllCardData[wUndersideUser][0])
									|| wOutCardUser == wUpsideUser && GetCardLogicValue(
											cbTurnCardData[0]) < GetCardLogicValue(m_cbAllCardData[wUpsideUser][0]))
							&& CanOutCard.cbEachHandCardCount[Index] != cbHandCardCount)
						bNoLargeCard = false;

					// 搜索有没有大牌（针对飞机带翅膀后面的带牌）
					for (int k = 3; k < CanOutCard.cbEachHandCardCount[Index]; ++k) {
						if (GetCardLogicValue(CanOutCard.cbCardData[Index][k]) >= 15
								&& CanOutCard.cbEachHandCardCount[Index] != cbHandCardCount)
							bNoLargeCard = false;
					}
					if (bNoLargeCard) {
						bFindCard = true;
						cbCanOutIndex = Index;
						cbMinLogicCardValue = GetCardLogicValue(CanOutCard.cbCardData[Index][0]);
					}
				}
			}

			if (bFindCard) {
				// 最大牌
				int cbLargestLogicCard = 0;
				if (wOutCardUser == wUndersideUser)
					cbLargestLogicCard = GetCardLogicValue(m_cbAllCardData[wUndersideUser][0]);
				else if (wOutCardUser == wUpsideUser)
					cbLargestLogicCard = GetCardLogicValue(m_cbAllCardData[wUpsideUser][0]);
				boolean bCanOut = true;

				// 王只压2
				if (GetCardLogicValue(cbTurnCardData[0]) < cbLargestLogicCard) {
					if (GetCardColor(CanOutCard.cbCardData[cbCanOutIndex][0]) == 0x40
							&& GetCardLogicValue(cbTurnCardData[0]) <= 14 && cbHandCardCount > 5) {
						bCanOut = false;
					}
				}

				// 双王判断
				if (GetCardLogicValue(CanOutCard.cbCardData[cbCanOutIndex][0]) >= 16 && cbHandCardCount >= 2
						&& cbHandCardData[0] == 0x4F && cbHandCardData[1] == 0x4E) {
					boolean bOutMissileCard = false;
					// 一手牌和一个炸弹
					int cbRemainCardData[] = new int[20], cbRemainCardCount = cbHandCardCount;
					Constants.CopyMemory(cbRemainCardData, cbHandCardData, cbHandCardCount);
					RemoveCard(cbRemainCardData, 2, cbRemainCardData, cbRemainCardCount);
					cbRemainCardCount -= 2;
					if (Constants.CT_ERROR != GetCardType(cbRemainCardData, cbRemainCardCount))
						bOutMissileCard = true;

					// 只剩少量牌
					int cbRemainLargestCard = GetCardLogicValue(cbRemainCardData[0]);
					if (cbRemainCardCount < 5 && cbRemainCardCount > 0 && GetCardLogicValue(cbRemainCardData[0]) >= 14)
						bOutMissileCard = true;

					// 炸后单牌数
					int cbSingleCardCount1 = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
							CanOutCard.cbCardData[cbCanOutIndex], CanOutCard.cbEachHandCardCount[cbCanOutIndex]);
					if (cbSingleCardCount1 <= 1 && GetCardLogicValue(cbRemainCardData[0]) >= 11)
						bOutMissileCard = true;

					// 还有小牌
					if (GetCardLogicValue(cbRemainCardData[0]) <= 10
							&& Constants.CT_ERROR == GetCardType(cbRemainCardData, cbRemainCardCount)
							&& (GetCardLogicValue(m_cbAllCardData[(1 + m_wBankerUser) % Constants.DDZ_PLAYER][0]) > 10
									|| GetCardLogicValue(
											m_cbAllCardData[(2 + m_wBankerUser) % Constants.DDZ_PLAYER][0]) > 10))
						bOutMissileCard = false;

					// 火箭扑克
					if (bOutMissileCard) {
						// 优先其他炸弹
						int cbIndex1 = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount - 1;

						OutCardResult.cbCardCount = CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[cbIndex1];
						Constants.CopyMemory(OutCardResult.cbResultCard,
								CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[cbIndex1], OutCardResult.cbCardCount);
						return;
					}
				}

				if (bCanOut) {
					// 设置变量
					OutCardResult.cbCardCount = CanOutCard.cbEachHandCardCount[cbCanOutIndex];
					Constants.CopyMemory(OutCardResult.cbResultCard, CanOutCard.cbCardData[cbCanOutIndex],
							CanOutCard.cbEachHandCardCount[cbCanOutIndex]);

					return;
				}
			}

			if (cbOutCardType == Constants.CT_SINGLE) {
				// 闲家的最大牌
				int cbLargestLogicCard = 0;
				if (wOutCardUser == wUndersideUser)
					cbLargestLogicCard = GetCardLogicValue(m_cbAllCardData[wUndersideUser][0]);
				else if (wOutCardUser == wUpsideUser)
					cbLargestLogicCard = GetCardLogicValue(m_cbAllCardData[wUpsideUser][0]);

				if (GetCardLogicValue(cbTurnCardData[0]) == 14
						|| GetCardLogicValue(cbTurnCardData[0]) >= cbLargestLogicCard
						|| (GetCardLogicValue(cbTurnCardData[0]) < cbLargestLogicCard - 1)
						|| (wOutCardUser == wUndersideUser && m_cbUserCardCount[wUndersideUser] <= 5
								|| wOutCardUser == wUpsideUser && m_cbUserCardCount[wUpsideUser] <= 5)) {
					// 取一张大于等于2而且要比闲家出的牌大的牌，
					int cbIndex1 = Constants.MAX_COUNT;
					for (int i = 0; i < cbHandCardCount; ++i)
						if (GetCardLogicValue(cbHandCardData[i]) > GetCardLogicValue(cbTurnCardData[0])
								&& GetCardLogicValue(cbHandCardData[i]) >= 15) {
							cbIndex1 = i;
						}
					if (cbIndex1 != Constants.MAX_COUNT) {
						// 设置变量
						OutCardResult.cbCardCount = 1;
						OutCardResult.cbResultCard[0] = cbHandCardData[cbIndex1];

						return;
					}
				}
			}

			int cbMinSingleCount = Constants.MAX_COUNT;
			int Index = 0;
			for (int i = 0; i < CardTypeResult[cbOutCardType].cbCardTypeCount; ++i) {
				int cbTmpCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
						CardTypeResult[cbOutCardType].cbCardData[i],
						CardTypeResult[cbOutCardType].cbEachHandCardCount[i]);
				if (cbMinSingleCount >= cbTmpCount) {
					cbMinSingleCount = cbTmpCount;
					Index = i;
				}
			}
			// 设置变量
			OutCardResult.cbCardCount = CardTypeResult[cbOutCardType].cbEachHandCardCount[Index];
			Constants.CopyMemory(OutCardResult.cbResultCard, CardTypeResult[cbOutCardType].cbCardData[Index],
					OutCardResult.cbCardCount);

			return;
		}

		// 还要考虑炸弹
		if (CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount > 0) {
			tagOutCardTypeResult_Server BomCard = CardTypeResult[Constants.CT_BOMB_CARD];
			int cbMinLogicValue = GetCardLogicValue(BomCard.cbCardData[0][0]);
			int Index = 0;
			for (int i = 0; i < BomCard.cbCardTypeCount; ++i) {
				if (cbMinLogicValue > GetCardLogicValue(BomCard.cbCardData[i][0])) {
					cbMinLogicValue = GetCardLogicValue(BomCard.cbCardData[i][0]);
					Index = i;
				}
			}

			boolean bOutBomb = false;

			// 另一闲家
			// int wOtherUser=INVALID_CHAIR ;
			// for(int wUser=0; wUser<GAME_PLAYER; ++wUser)
			// if(wUser!=wOutCardUser && wUser!=m_wBankerUser)
			// wOtherUser=wOtherUser
			// ;

			// 一手牌和一个炸弹
			int cbRemainCardData[] = new int[20], cbRemainCardCount = cbHandCardCount;
			Constants.CopyMemory(cbRemainCardData, cbHandCardData, cbHandCardCount);
			RemoveCard(BomCard.cbCardData[Index], BomCard.cbEachHandCardCount[Index], cbRemainCardData,
					cbRemainCardCount);
			cbRemainCardCount -= BomCard.cbEachHandCardCount[Index];
			if (Constants.CT_ERROR != GetCardType(cbRemainCardData, cbRemainCardCount))
				bOutBomb = true;

			// 炸后单牌数
			int cbSingleCardCount1 = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, BomCard.cbCardData[Index],
					BomCard.cbEachHandCardCount[Index]);
			if (cbSingleCardCount1 == 0 && GetCardLogicValue(cbRemainCardData[0]) > GetCardLogicValue(
					m_cbAllCardData[wUpsideUser == wOutCardUser ? wUndersideUser : wUpsideUser][0]))
				bOutBomb = true;

			// 只剩一手
			int cbRemainCardType = GetCardType(m_cbAllCardData[wOutCardUser], m_cbUserCardCount[wOutCardUser]);
			if (cbRemainCardType > Constants.CT_ERROR && cbRemainCardType < Constants.CT_FOUR_LINE_TAKE_ONE
					&& GetCardLogicValue(m_cbAllCardData[wOutCardUser][0]) < 15 && cbSingleCardCount1 < 2
					&& (GetCardLogicValue(cbRemainCardData[0]) >= GetCardLogicValue(m_cbAllCardData[wUndersideUser][0])
							&& GetCardLogicValue(cbRemainCardData[0]) >= GetCardLogicValue(
									m_cbAllCardData[wUpsideUser][0])))
				bOutBomb = true;

			// 反春天
			if (cbRemainCardType != Constants.CT_ERROR && m_lBankerOutCardCount == 1)
				bOutBomb = true;

			// 只剩少量牌
			int cbRemainLargestCard = GetCardLogicValue(cbRemainCardData[0]);
			if (cbRemainCardCount < 5 && cbRemainCardCount > 0
					&& (cbRemainLargestCard != GetCardLogicValue(BomCard.cbCardData[Index][0]))
					&& cbRemainLargestCard > GetCardLogicValue(m_cbAllCardData[wOutCardUser][0])
					&& cbRemainLargestCard > 14)
				bOutBomb = true;

			// 分析扑克
			tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();
			AnalysebCardData(cbRemainCardData, cbRemainCardCount, AnalyseResult);

			if (m_cbUserCardCount[wOutCardUser] == 1 && (AnalyseResult.cbDoubleCount * 2
					+ AnalyseResult.cbThreeCount * 3 + AnalyseResult.cbFourCount * 4 + 1 >= cbRemainCardCount))
				bOutBomb = true;

			// 设置变量
			if (bOutBomb) {
				OutCardResult.cbCardCount = BomCard.cbEachHandCardCount[Index];
				Constants.CopyMemory(OutCardResult.cbResultCard, BomCard.cbCardData[Index],
						BomCard.cbEachHandCardCount[Index]);
			}
			return;
		}

		return;
	}

	// 地主上家（先出牌）
	void UpsideOfBankerOutCard(int cbHandCardData[], int cbHandCardCount, int wMeChairID,
			tagOutCardResult_Server OutCardResult) {

		// 地主只有一张，从大到小出牌
		if (m_cbUserCardCount[m_wBankerUser] == 1) {
			int cbSingleCardData[] = new int[Constants.MAX_COUNT];
			int cbSingleCardCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0, cbSingleCardData);

			// 只剩单牌
			if (cbSingleCardCount == cbHandCardCount) {
				OutCardResult.cbCardCount = 1;
				OutCardResult.cbResultCard[0] = cbHandCardData[0];

				return;
			}
		}

		// 零下标没用
		tagOutCardTypeResult_Server CardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
		tagOutCardTypeResult_Server.init(CardTypeResult);
		int cbLineCard[] = new int[Constants.MAX_COUNT];
		int cbThreeLineCard[] = new int[Constants.MAX_COUNT];
		int cbDoubleLineCard[] = new int[Constants.MAX_COUNT];
		int cbLineCardCount = 0;
		int cbThreeLineCardCount = 0;
		int cbDoubleLineCount = 0;
		cbLineCardCount = GetAllLineCard(cbHandCardData, cbHandCardCount, cbLineCard, cbLineCardCount);
		cbThreeLineCardCount = GetAllThreeCard(cbHandCardData, cbHandCardCount, cbThreeLineCard, cbThreeLineCardCount);
		cbDoubleLineCount = GetAllDoubleCard(cbHandCardData, cbHandCardCount, cbDoubleLineCard, cbDoubleLineCount);

		// 判断可否出完
		int cbSingleCardCount = Constants.MAX_COUNT + Constants.CT_MISSILE_CARD;
		boolean bFindBestCard = false;
		AnalyseOutCardType(cbHandCardData, cbHandCardCount, CardTypeResult);
		for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType)
			if (CardTypeResult[cbCardType].cbCardTypeCount > 0) {
				for (int lIndex = 0; lIndex < CardTypeResult[cbCardType].cbCardTypeCount; ++lIndex) {
					int wMeChairID1 = (m_wBankerUser + 2) % Constants.DDZ_PLAYER;

					if (TestOutAllCard(wMeChairID1, CardTypeResult[cbCardType].cbCardData[lIndex],
							CardTypeResult[cbCardType].cbEachHandCardCount[lIndex], true)) {
						// 计算单牌
						int cbTmpSingleCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
								CardTypeResult[cbCardType].cbCardData[lIndex],
								CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);

						// 结果判断
						if (cbTmpSingleCount >= Constants.MAX_COUNT)
							continue;

						// 炸弹优先级排后
						int cbBombCardType = GetCardType(CardTypeResult[cbCardType].cbCardData[lIndex],
								CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);
						if (cbBombCardType == Constants.CT_BOMB_CARD)
							cbTmpSingleCount += 4;
						else if (cbBombCardType == Constants.CT_MISSILE_CARD)
							cbTmpSingleCount += 5;
						else if (15 == GetCardLogicValue(CardTypeResult[cbCardType].cbCardData[lIndex][0]))
							cbTmpSingleCount += 2;
						else if (15 < GetCardLogicValue(CardTypeResult[cbCardType].cbCardData[lIndex][0]))
							cbTmpSingleCount += 3;

						//// 改变权值
						// if (cbBombCardType != CT_ERROR) cbTmpSingleCount +=
						//// cbBombCardType ;

						if (cbTmpSingleCount <= cbSingleCardCount) {
							// 设置变量
							OutCardResult.cbCardCount = CardTypeResult[cbCardType].cbEachHandCardCount[lIndex];
							Constants.CopyMemory(OutCardResult.cbResultCard,
									CardTypeResult[cbCardType].cbCardData[lIndex],
									CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);
							cbSingleCardCount = cbTmpSingleCount;

							bFindBestCard = true;
						}
					}
				}
			}
		// 直接返回
		if (bFindBestCard)
			return;

		// 对王和两单
		if (cbHandCardCount == 4 && GetCardLogicValue(cbHandCardData[1]) == 16 && m_cbUserCardCount[m_wBankerUser] == 1
				&& GetCardLogicValue(cbHandCardData[2]) < GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0])) {
			OutCardResult.cbCardCount = 1;
			OutCardResult.cbResultCard[0] = cbHandCardData[2];
			return;
		}

		// 四带牌型判断
		if (AnalyseFourCardType(cbHandCardData, cbHandCardCount, m_cbAllCardData[m_wBankerUser],
				m_cbUserCardCount[m_wBankerUser], OutCardResult)) {
			return;
		}

		// 如果有顺牌和单只或一对，而且单只或对比地主的小，则先出顺
		{
			if (cbLineCardCount + 1 == cbHandCardCount
					&& Constants.CT_SINGLE == GetCardType(cbLineCard, cbLineCardCount)) {
				OutCardResult.cbCardCount = cbLineCardCount;
				Constants.CopyMemory(OutCardResult.cbResultCard, cbLineCard, cbLineCardCount);
			} else if (cbThreeLineCardCount + 1 == cbHandCardCount
					&& Constants.CT_THREE_LINE == GetCardType(cbThreeLineCard, cbThreeLineCardCount)) {
				OutCardResult.cbCardCount = cbThreeLineCardCount;
				Constants.CopyMemory(OutCardResult.cbResultCard, cbThreeLineCard, cbThreeLineCardCount);
			} else if (cbDoubleLineCount + 1 == cbHandCardCount
					&& Constants.CT_DOUBLE_LINE == GetCardType(cbDoubleLineCard, cbDoubleLineCount)) {
				OutCardResult.cbCardCount = cbDoubleLineCount;
				Constants.CopyMemory(OutCardResult.cbResultCard, cbDoubleLineCard, cbDoubleLineCount);
			}
			// 双王炸弹和一手
			else if (cbHandCardCount > 2 && cbHandCardData[0] == 0x4f && cbHandCardData[1] == 0x4e
					&& Constants.CT_ERROR != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)
					&& Constants.CT_FOUR_LINE_TAKE_ONE != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)
					&& Constants.CT_FOUR_LINE_TAKE_TWO != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)) {
				OutCardResult.cbCardCount = 2;
				OutCardResult.cbResultCard[0] = 0x4f;
				OutCardResult.cbResultCard[1] = 0x4e;
			}

			if (OutCardResult.cbCardCount > 0) {
				return;
			}
		}
		// 对王加一只
		if (cbHandCardCount == 3 && GetCardColor(cbHandCardData[0]) == 0x40
				&& GetCardColor(cbHandCardData[1]) == 0x40) {
			OutCardResult.cbCardCount = 2;
			OutCardResult.cbResultCard[0] = 0x4f;
			OutCardResult.cbResultCard[1] = 0x4e;
			return;
		}
		// 对王
		else if (cbHandCardCount == 2 && GetCardColor(cbHandCardData[0]) == 0x40
				&& GetCardColor(cbHandCardData[1]) == 0x40) {
			OutCardResult.cbCardCount = 2;
			OutCardResult.cbResultCard[0] = 0x4f;
			OutCardResult.cbResultCard[1] = 0x4e;
			return;
		}
		// 只剩一手牌
		else if (Constants.CT_ERROR != GetCardType(cbHandCardData, cbHandCardCount)
				&& Constants.CT_FOUR_LINE_TAKE_ONE != GetCardType(cbHandCardData, cbHandCardCount)
				&& Constants.CT_FOUR_LINE_TAKE_TWO != GetCardType(cbHandCardData, cbHandCardCount)) {
			OutCardResult.cbCardCount = cbHandCardCount;
			Constants.CopyMemory(OutCardResult.cbResultCard, cbHandCardData, cbHandCardCount);
			return;
		}

		// 只剩一张和一手
		if (cbHandCardCount >= 2) {
			// 地主扑克
			tagOutCardTypeResult_Server BankerCanOutCardType1[] = new tagOutCardTypeResult_Server[13];
			tagOutCardTypeResult_Server.init(BankerCanOutCardType1);
			tagOutCardTypeResult_Server BankerCanOutCardType2[] = new tagOutCardTypeResult_Server[13];
			tagOutCardTypeResult_Server.init(BankerCanOutCardType2);
			int cbFirstHandCardType = GetCardType(cbHandCardData, cbHandCardCount - 1);
			int cbSecondHandCardType = GetCardType(cbHandCardData, 1, cbHandCardCount - 1);

			// 是否有炸
			int cbAllBombCardData[] = new int[Constants.MAX_COUNT], cbAllBombCount = 0;
			cbAllBombCount = GetAllBomCard(cbHandCardData, cbHandCardCount, cbAllBombCardData, cbAllBombCount);

			// 没有炸弹
			if (cbAllBombCount <= 0 && cbFirstHandCardType != Constants.CT_THREE_LINE_TAKE_ONE
					&& cbFirstHandCardType != Constants.CT_THREE_LINE_TAKE_TWO) {
				// 地主可以出的牌
				if (cbFirstHandCardType != Constants.CT_ERROR)
					AnalyseOutCardType(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser], cbHandCardData,
							cbHandCardCount - 1, BankerCanOutCardType1);
				if (cbSecondHandCardType != Constants.CT_ERROR)
					AnalyseOutCardType(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser], cbHandCardData,
							1, cbHandCardCount - 1, BankerCanOutCardType2);

				if (cbSecondHandCardType != Constants.CT_ERROR
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO
						&& BankerCanOutCardType2[cbSecondHandCardType].cbCardTypeCount == 0
						&& BankerCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0) {
					OutCardResult.cbCardCount = cbHandCardCount - 1;
					Constants.CopyMemory(OutCardResult.cbResultCard, cbHandCardData, 1, cbHandCardCount - 1);
					return;
				}

				if (cbFirstHandCardType != Constants.CT_ERROR && cbFirstHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbFirstHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO
						&& BankerCanOutCardType1[cbFirstHandCardType].cbCardTypeCount == 0
						&& BankerCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0) {
					OutCardResult.cbCardCount = cbHandCardCount - 1;
					Constants.CopyMemory(OutCardResult.cbResultCard, cbHandCardData, cbHandCardCount - 1);
					return;
				}

				if (GetCardLogicValue(cbHandCardData[0]) >= GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0])
						&& Constants.CT_ERROR != cbSecondHandCardType
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO
						&& BankerCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0) {
					OutCardResult.cbCardCount = 1;
					OutCardResult.cbResultCard[0] = cbHandCardData[0];
					return;
				}

				if (Constants.CT_ERROR != cbSecondHandCardType
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO
						&& BankerCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0) {
					OutCardResult.cbCardCount = cbHandCardCount - 1;
					Constants.CopyMemory(OutCardResult.cbResultCard, cbHandCardData, 1, cbHandCardCount - 1);
					return;
				}
			}
			// 还有炸弹
			else {
				// 除去炸后的牌
				int cbRemainCard[] = new int[Constants.MAX_COUNT], cbRemainCount = 0;
				Constants.CopyMemory(cbRemainCard, cbHandCardData, cbHandCardCount);
				cbRemainCount = cbHandCardCount;
				RemoveCard(cbAllBombCardData, cbAllBombCount, cbRemainCard, cbRemainCount);
				cbRemainCount -= cbAllBombCount;
				if (GetCardType(cbRemainCard, cbRemainCount) != Constants.CT_ERROR) {
					OutCardResult.cbCardCount = cbRemainCount;
					Constants.CopyMemory(OutCardResult.cbResultCard, cbRemainCard, cbRemainCount);
					return;
				}
			}
		}

		// 对牌接牌判断
		int wFriendID = (m_wBankerUser + 1) % Constants.DDZ_PLAYER;
		if (1 == m_cbUserCardCount[m_wBankerUser] && cbHandCardCount >= 2 && m_cbUserCardCount[wFriendID] >= 2) {
			tagAnalyseResult_Server MeAnalyseResult = new tagAnalyseResult_Server();

			// 分析扑克
			AnalysebCardData(cbHandCardData, cbHandCardCount, MeAnalyseResult);

			tagAnalyseResult_Server FriendAnalyseResult = new tagAnalyseResult_Server();

			// 分析扑克
			AnalysebCardData(m_cbAllCardData[wFriendID], m_cbUserCardCount[wFriendID], FriendAnalyseResult);

			// 对牌判断
			if ((m_cbUserCardCount[wFriendID] == (FriendAnalyseResult.cbDoubleCount * 2
					+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4)
					|| m_cbUserCardCount[wFriendID] == (FriendAnalyseResult.cbDoubleCount * 2
							+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4 + 1))
					&& MeAnalyseResult.cbDoubleCount > 0 && FriendAnalyseResult.cbDoubleCount > 0) {
				// 最小对子
				int cbMeLeastDoubleCardLogic = GetCardLogicValue(
						MeAnalyseResult.cbDoubleCardData[MeAnalyseResult.cbDoubleCount * 2 - 2]);
				// 最大对子
				int cbFriendLargestDoublecardLogic = GetCardLogicValue(FriendAnalyseResult.cbDoubleCardData[0]);

				// 出对判断
				if (cbMeLeastDoubleCardLogic < 14 && cbMeLeastDoubleCardLogic < cbFriendLargestDoublecardLogic) {
					OutCardResult.cbCardCount = 2;
					OutCardResult.cbResultCard[0] = MeAnalyseResult.cbDoubleCardData[MeAnalyseResult.cbDoubleCount * 2
							- 2];
					OutCardResult.cbResultCard[1] = MeAnalyseResult.cbDoubleCardData[MeAnalyseResult.cbDoubleCount * 2
							- 1];
					return;
				}

			}
		}

		// 下家为地主，而且地主扑克少于5张
		// if(m_cbUserCardCount[m_wBankerUser]<=5)
		{
			// 分析扑克
			tagOutCardTypeResult_Server MeOutCardTypeResult[] = new tagOutCardTypeResult_Server[13];
			tagOutCardTypeResult_Server.init(MeOutCardTypeResult);
			AnalyseOutCardType(cbHandCardData, cbHandCardCount, MeOutCardTypeResult);

			// 对家扑克
			int wFriendID1 = 0;
			for (int wChairID = 0; wChairID < Constants.DDZ_PLAYER; ++wChairID)
				if (wChairID != m_wBankerUser && wMeChairID != wChairID)
					wFriendID1 = wChairID;

			// 计算单牌
			int cbMinSingleCardCount[] = new int[4];
			cbMinSingleCardCount[0] = Constants.MAX_COUNT;
			cbMinSingleCardCount[1] = Constants.MAX_COUNT;
			cbMinSingleCardCount[2] = Constants.MAX_COUNT;
			cbMinSingleCardCount[3] = Constants.MAX_COUNT;
			int cbIndex[] = { 0, 0, 0, 0 };
			int cbOutcardType[] = { Constants.CT_ERROR, Constants.CT_ERROR, Constants.CT_ERROR, Constants.CT_ERROR };
			int cbMinValue = Constants.MAX_COUNT;
			int cbMinSingleCountInFour = Constants.MAX_COUNT;
			int cbMinCardType = Constants.CT_ERROR;
			int cbMinIndex = 0;

			// 分析地主对牌
			int cbBankerDoubleCardData[] = new int[Constants.MAX_COUNT], cbBankerDoubleCardCount = 0;
			cbBankerDoubleCardCount = GetAllDoubleCard(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser], cbBankerDoubleCardData,
					cbBankerDoubleCardCount);

			// 除炸弹外的牌
			for (int cbCardType = Constants.CT_DOUBLE; cbCardType < Constants.CT_BOMB_CARD; ++cbCardType) {
				tagOutCardTypeResult_Server tmpCardResult = MeOutCardTypeResult[cbCardType];

				// 相同牌型，相同长度，单连，对连等相同牌型可能长度不一样
				int cbThisHandCardCount = Constants.MAX_COUNT;

				// 地主扑克
				tagOutCardTypeResult_Server BankerCanOutCard[] = new tagOutCardTypeResult_Server[13];
				tagOutCardTypeResult_Server.init(BankerCanOutCard);
				tagOutCardTypeResult_Server FriendOutCardTypeResult[] = new tagOutCardTypeResult_Server[13];
				tagOutCardTypeResult_Server.init(FriendOutCardTypeResult);

				for (int i = 0; i < tmpCardResult.cbCardTypeCount; ++i) {
					// 拆三条判断
					if (cbCardType == Constants.CT_DOUBLE) {
						tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();

						AnalysebCardData(cbHandCardData, cbHandCardCount, AnalyseResult);
						if (AnalyseResult.cbSignedCount + AnalyseResult.cbThreeCount * 3 == cbHandCardCount) {
							boolean bContinue = false;
							for (int cbThreeIndex = 0; cbThreeIndex < AnalyseResult.cbThreeCount; ++cbThreeIndex)
								if (GetCardValue(tmpCardResult.cbCardData[i][0]) == GetCardValue(
										AnalyseResult.cbThreeCardData[3 * cbThreeIndex])) {
									bContinue = true;
									break;
								}
							if (bContinue)
								continue;
						}
					}

					int cbTmpCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, tmpCardResult.cbCardData[i],
							tmpCardResult.cbEachHandCardCount[i]);

					// 拦截对牌
					if (cbCardType == Constants.CT_DOUBLE && cbBankerDoubleCardCount > 0
							&& GetCardLogicValue(cbBankerDoubleCardData[cbBankerDoubleCardCount - 1]) < 10
							&& GetCardLogicValue(tmpCardResult.cbCardData[i][0]) < GetCardLogicValue(
									cbBankerDoubleCardData[cbBankerDoubleCardCount - 1])
							&& GetCardLogicValue(tmpCardResult.cbCardData[0][0]) >= 10
							&& GetCardLogicValue(tmpCardResult.cbCardData[0][0]) < 14)
						continue;

					// 重新分析
					if (tmpCardResult.cbEachHandCardCount[i] != cbThisHandCardCount) {
						cbThisHandCardCount = tmpCardResult.cbEachHandCardCount[i];
						AnalyseOutCardType(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser],
								tmpCardResult.cbCardData[i], tmpCardResult.cbEachHandCardCount[i], BankerCanOutCard);
						AnalyseOutCardType(m_cbAllCardData[wFriendID1], m_cbUserCardCount[wFriendID1],
								tmpCardResult.cbCardData[i], tmpCardResult.cbEachHandCardCount[i],
								FriendOutCardTypeResult);
					}

					int cbMaxValue = 0;
					int Index = 0;

					// 针对顺子，三条的大牌
					int cbCurrentCardType = GetCardType(tmpCardResult.cbCardData[i], cbThisHandCardCount);
					if (cbThisHandCardCount != cbHandCardCount && cbCurrentCardType >= Constants.CT_SINGLE_LINE
							&& cbCurrentCardType <= Constants.CT_THREE_LINE_TAKE_TWO
							&& (GetCardLogicValue(
									tmpCardResult.cbCardData[i][cbThisHandCardCount - 1]) > GetCardLogicValue(
											cbHandCardData[cbHandCardCount - 2])
									|| GetCardLogicValue(tmpCardResult.cbCardData[i][0]) >= 11)) {
						int cbRemainCardData[] = new int[Constants.MAX_COUNT], cbRemainCardCount = 0;
						Constants.CopyMemory(cbRemainCardData, cbHandCardData, cbHandCardCount);
						cbRemainCardCount = cbHandCardCount;

						// 移除扑克
						RemoveCard(tmpCardResult.cbCardData[i], cbThisHandCardCount, cbRemainCardData,
								cbRemainCardCount);
						cbRemainCardCount -= cbThisHandCardCount;

						// 最大扑克
						int cbCurrentLargestLogicCard = GetCardLogicValue(tmpCardResult.cbCardData[i][0]);

						if (GetCardType(cbRemainCardData, cbRemainCardCount) == Constants.CT_ERROR
								&& (cbCurrentCardType >= Constants.CT_THREE_LINE_TAKE_ONE
										&& cbCurrentCardType <= Constants.CT_THREE_LINE_TAKE_TWO
										&& cbCurrentLargestLogicCard >= 11 && cbThisHandCardCount <= 5
										|| cbCurrentCardType == Constants.CT_SINGLE_LINE && cbThisHandCardCount <= 6
												&& cbCurrentLargestLogicCard >= 12
										|| cbCurrentCardType >= Constants.CT_DOUBLE_LINE
												&& cbCurrentCardType <= Constants.CT_THREE_LINE
												&& cbCurrentLargestLogicCard >= 12 && cbThisHandCardCount <= 8)) {
							// 暂时不出
							if (cbCurrentCardType >= Constants.CT_SINGLE_LINE
									&& cbCurrentCardType <= Constants.CT_THREE_LINE
									&& GetCardLogicValue(
											tmpCardResult.cbCardData[i][cbThisHandCardCount - 1]) > GetCardLogicValue(
													cbHandCardData[cbHandCardCount - 3]))
								continue;

							if (cbCurrentCardType >= Constants.CT_THREE_LINE_TAKE_ONE
									&& cbCurrentCardType <= Constants.CT_THREE_LINE_TAKE_TWO
									&& GetCardLogicValue(tmpCardResult.cbCardData[i][0]) > GetCardLogicValue(
											cbHandCardData[cbHandCardCount - 3]))
								continue;
						}
					}

					// 地主可以压牌，而且队友不可以压地主
					if ((BankerCanOutCard[cbCardType].cbCardTypeCount > 0
							&& FriendOutCardTypeResult[cbCardType].cbCardTypeCount == 0)
							|| (BankerCanOutCard[cbCardType].cbCardTypeCount > 0
									&& FriendOutCardTypeResult[cbCardType].cbCardTypeCount > 0
									&& GetCardLogicValue(
											FriendOutCardTypeResult[cbCardType].cbCardData[0][0]) <= GetCardLogicValue(
													BankerCanOutCard[cbCardType].cbCardData[0][0]))) {
						// 地主跑掉
						if (BankerCanOutCard[cbCardType].cbEachHandCardCount[0] > 0
								&& m_cbUserCardCount[m_wBankerUser] <= BankerCanOutCard[cbCardType].cbEachHandCardCount[0]
										+ 1)
							continue;

						// 自己不可以再拿回牌权
						if (GetCardLogicValue(tmpCardResult.cbCardData[0][0]) < GetCardLogicValue(
								BankerCanOutCard[cbCardType].cbCardData[0][0])
								&& BankerCanOutCard[cbCardType].cbCardTypeCount > 0)
							continue;
					}
					// 是否有大牌
					if (tmpCardResult.cbEachHandCardCount[i] != cbHandCardCount) {
						boolean bHaveLargeCard = false;
						for (int j = 0; j < tmpCardResult.cbEachHandCardCount[i]; ++j)
							if (GetCardLogicValue(tmpCardResult.cbCardData[i][j]) >= 15)
								bHaveLargeCard = true;
						if (cbCardType != Constants.CT_SINGLE_LINE && cbCardType != Constants.CT_DOUBLE_LINE
								&& GetCardLogicValue(tmpCardResult.cbCardData[i][0]) == 14)
							bHaveLargeCard = true;

						if (bHaveLargeCard)
							continue;
					}

					// 地主是否可以走掉，这里都没有考虑炸弹
					if (tmpCardResult.cbEachHandCardCount[i] == m_cbUserCardCount[m_wBankerUser]
							&& cbCardType == GetCardType(m_cbAllCardData[m_wBankerUser],
									m_cbUserCardCount[m_wBankerUser])
							&& GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0]) > GetCardLogicValue(
									tmpCardResult.cbCardData[i][0]))
						continue;

					// 搜索cbMinSingleCardCount[4]的最大值
					for (int j = 0; j < 4; ++j) {
						if (cbMinSingleCardCount[j] >= cbTmpCount) {
							cbMinSingleCardCount[j] = cbTmpCount;
							cbIndex[j] = i;
							cbOutcardType[j] = cbCardType;
							break;
						}
					}

					// 保存最小值
					if (cbMinSingleCountInFour >= cbTmpCount) {
						// 最小牌型
						cbMinCardType = cbCardType;
						// 最小牌型中的最小单牌
						cbMinSingleCountInFour = cbTmpCount;
						// 最小牌型中的最小牌
						cbMinIndex = i;
					}
				}
			}

			if (cbMinSingleCountInFour >= AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0) + 3
					&& m_cbUserCardCount[m_wBankerUser] > 4)
				cbMinSingleCountInFour = Constants.MAX_COUNT;

			if (cbMinSingleCountInFour != Constants.MAX_COUNT) {
				int Index = cbMinIndex;

				// 选择最小牌
				for (int i = 0; i < 4; ++i) {
					if (cbOutcardType[i] == cbMinCardType && cbMinSingleCardCount[i] <= cbMinSingleCountInFour
							&& GetCardLogicValue(
									MeOutCardTypeResult[cbMinCardType].cbCardData[cbIndex[i]][0]) < GetCardLogicValue(
											MeOutCardTypeResult[cbMinCardType].cbCardData[Index][0]))
						Index = cbIndex[i];
				}

				// 对王加一只
				if (cbHandCardCount == 3 && GetCardColor(cbHandCardData[0]) == 0x40
						&& GetCardColor(cbHandCardData[1]) == 0x40) {
					OutCardResult.cbCardCount = 2;
					OutCardResult.cbResultCard[0] = 0x4f;
					OutCardResult.cbResultCard[1] = 0x4e;
					return;
				}
				// 对王
				else if (cbHandCardCount == 2 && GetCardColor(cbHandCardData[0]) == 0x40
						&& GetCardColor(cbHandCardData[1]) == 0x40) {
					OutCardResult.cbCardCount = 2;
					OutCardResult.cbResultCard[0] = 0x4f;
					OutCardResult.cbResultCard[1] = 0x4e;
					return;
				} else {
					// 设置变量
					OutCardResult.cbCardCount = MeOutCardTypeResult[cbMinCardType].cbEachHandCardCount[Index];
					Constants.CopyMemory(OutCardResult.cbResultCard,
							MeOutCardTypeResult[cbMinCardType].cbCardData[Index],
							MeOutCardTypeResult[cbMinCardType].cbEachHandCardCount[Index]);
					return;
				}
			}

			// 如果地主扑克少于5，还没有找到适合的牌则从大出到小
			if (OutCardResult.cbCardCount <= 0 && m_cbUserCardCount[m_wBankerUser] <= 5) {
				// 只有一张牌时不能放地主走
				if (m_cbUserCardCount[m_wBankerUser] == 1
						&& MeOutCardTypeResult[Constants.CT_SINGLE].cbCardTypeCount > 0) {
					int Index = Constants.MAX_COUNT;
					for (int i = 0; i < MeOutCardTypeResult[Constants.CT_SINGLE].cbCardTypeCount; ++i) {
						if (GetCardLogicValue(
								MeOutCardTypeResult[Constants.CT_SINGLE].cbCardData[i][0]) >= GetCardLogicValue(
										m_cbAllCardData[m_wBankerUser][0])) {
							Index = i;
						} else
							break;
					}

					if (Constants.MAX_COUNT != Index) {
						OutCardResult.cbCardCount = MeOutCardTypeResult[Constants.CT_SINGLE].cbEachHandCardCount[Index];
						Constants.CopyMemory(OutCardResult.cbResultCard,
								MeOutCardTypeResult[Constants.CT_SINGLE].cbCardData[Index], OutCardResult.cbCardCount);
						return;
					}
				}
			}
		}

		int cbFirstCard = 0;
		// 过滤王和2
		for (int i = 0; i < cbHandCardCount; ++i)
			if (GetCardLogicValue(cbHandCardData[i]) < 15) {
				cbFirstCard = i;
				break;
			}

		if (cbFirstCard < cbHandCardCount - 1)
			AnalyseOutCardType(cbHandCardData, cbFirstCard, cbHandCardCount - cbFirstCard, CardTypeResult);
		else
			AnalyseOutCardType(cbHandCardData, cbHandCardCount, CardTypeResult);

		// 计算单牌
		int cbMinSingleCardCount[] = new int[4];
		cbMinSingleCardCount[0] = Constants.MAX_COUNT;
		cbMinSingleCardCount[1] = Constants.MAX_COUNT;
		cbMinSingleCardCount[2] = Constants.MAX_COUNT;
		cbMinSingleCardCount[3] = Constants.MAX_COUNT;
		int cbIndex[] = { 0, 0, 0, 0 };
		int cbOutcardType[] = { Constants.CT_ERROR, Constants.CT_ERROR, Constants.CT_ERROR, Constants.CT_ERROR };
		int cbMinValue = Constants.MAX_COUNT;
		int cbMinSingleCountInFour = Constants.MAX_COUNT;
		int cbMinCardType = Constants.CT_ERROR;
		int cbMinIndex = 0;

		// 分析地主单牌
		int cbBankerSingleCardData[] = new int[Constants.MAX_COUNT];
		int cbBankerSingleCardCount = AnalyseSinleCardCount(m_cbAllCardData[m_wBankerUser],
				m_cbUserCardCount[m_wBankerUser], null, 0, cbBankerSingleCardData);
		int cbBankerSingleCardLogic = 0;
		if (cbBankerSingleCardCount >= 2
				&& GetCardLogicValue(cbBankerSingleCardData[cbBankerSingleCardCount - 2]) <= 10)
			cbBankerSingleCardLogic = GetCardLogicValue(cbBankerSingleCardData[cbBankerSingleCardCount - 2]);
		else if (cbBankerSingleCardCount >= 2
				&& GetCardLogicValue(cbBankerSingleCardData[cbBankerSingleCardCount - 1]) <= 10)
			cbBankerSingleCardLogic = GetCardLogicValue(cbBankerSingleCardData[cbBankerSingleCardCount - 1]);
		else if (cbBankerSingleCardCount > 0 && GetCardLogicValue(cbBankerSingleCardData[0]) <= 10)
			cbBankerSingleCardLogic = GetCardLogicValue(cbBankerSingleCardData[0]);

		// 分析地主对牌
		int cbBankerDoubleCardData[] = new int[Constants.MAX_COUNT], cbBankerDoubleCardCount = 0;
		cbBankerDoubleCardCount = GetAllDoubleCard(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser], cbBankerDoubleCardData,
				cbBankerDoubleCardCount);

		// 除炸弹外的牌
		for (int cbCardType = Constants.CT_SINGLE; cbCardType < Constants.CT_BOMB_CARD; ++cbCardType) {
			tagOutCardTypeResult_Server tmpCardResult = CardTypeResult[cbCardType];
			for (int i = 0; i < tmpCardResult.cbCardTypeCount; ++i) {
				// 不能放走地主小牌
				if (cbCardType == Constants.CT_SINGLE && cbBankerSingleCardCount > 0
						&& GetCardLogicValue(tmpCardResult.cbCardData[i][0]) < cbBankerSingleCardLogic)
					continue;

				// 拦截对牌
				if (cbCardType == Constants.CT_DOUBLE && cbBankerDoubleCardCount > 0
						&& GetCardLogicValue(cbBankerDoubleCardData[cbBankerDoubleCardCount - 1]) < 10
						&& GetCardLogicValue(tmpCardResult.cbCardData[i][0]) < GetCardLogicValue(
								cbBankerDoubleCardData[cbBankerDoubleCardCount - 1])
						&& GetCardLogicValue(tmpCardResult.cbCardData[0][0]) >= 10
						&& GetCardLogicValue(tmpCardResult.cbCardData[0][0]) < 14)
					continue;

				// 针对顺子，三条的大牌
				if (tmpCardResult.cbEachHandCardCount[i] != cbHandCardCount && cbCardType >= Constants.CT_SINGLE_LINE
						&& cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO

						&& (GetCardLogicValue(tmpCardResult.cbCardData[i][tmpCardResult.cbEachHandCardCount[i]
								- 1]) > GetCardLogicValue(cbHandCardData[cbHandCardCount - 2])
								|| GetCardLogicValue(tmpCardResult.cbCardData[i][0]) >= 11)) {
					int cbRemainCardData[] = new int[Constants.MAX_COUNT], cbRemainCardCount;
					Constants.CopyMemory(cbRemainCardData, cbHandCardData, cbHandCardCount);
					cbRemainCardCount = cbHandCardCount;

					// 移除扑克
					RemoveCard(tmpCardResult.cbCardData[i], tmpCardResult.cbEachHandCardCount[i], cbRemainCardData,
							cbRemainCardCount);
					cbRemainCardCount -= tmpCardResult.cbEachHandCardCount[i];

					// 最大扑克
					int cbCurrentLargestLogicCard = GetCardLogicValue(tmpCardResult.cbCardData[i][0]);

					if (GetCardType(cbRemainCardData, cbRemainCardCount) == Constants.CT_ERROR
							&& (cbCardType >= Constants.CT_THREE_LINE_TAKE_ONE
									&& cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO && cbCurrentLargestLogicCard >= 11
									&& tmpCardResult.cbEachHandCardCount[i] <= 5
									|| cbCardType == Constants.CT_SINGLE_LINE
											&& tmpCardResult.cbEachHandCardCount[i] <= 6
											&& cbCurrentLargestLogicCard >= 12
									|| cbCardType >= Constants.CT_DOUBLE_LINE && cbCardType <= Constants.CT_THREE_LINE
											&& cbCurrentLargestLogicCard >= 12
											&& tmpCardResult.cbEachHandCardCount[i] <= 8)) {
						// 暂时不出
						if (cbCardType >= Constants.CT_SINGLE_LINE && cbCardType <= Constants.CT_THREE_LINE
								&& GetCardLogicValue(tmpCardResult.cbCardData[i][tmpCardResult.cbEachHandCardCount[i]
										- 1]) > GetCardLogicValue(cbHandCardData[cbHandCardCount - 3]))
							continue;

						if (cbCardType >= Constants.CT_THREE_LINE_TAKE_ONE
								&& cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO
								&& GetCardLogicValue(tmpCardResult.cbCardData[i][0]) > GetCardLogicValue(
										cbHandCardData[cbHandCardCount - 3]))
							continue;
					}
				}

				int cbTmpCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, tmpCardResult.cbCardData[i],
						tmpCardResult.cbEachHandCardCount[i]);

				int cbMaxValue = 0;
				int Index = 0;

				// 搜索cbMinSingleCardCount[4]的最大值
				for (int j = 0; j < 4; ++j) {
					if (cbMinSingleCardCount[j] >= cbTmpCount) {
						cbMinSingleCardCount[j] = cbTmpCount;
						cbIndex[j] = i;
						cbOutcardType[j] = cbCardType;
						break;
					}
				}

				// 保存最小值
				if (cbMinSingleCountInFour >= cbTmpCount) {
					// 最小牌型
					cbMinCardType = cbCardType;
					// 最小牌型中的最小单牌
					cbMinSingleCountInFour = cbTmpCount;
					// 最小牌型中的最小牌
					cbMinIndex = i;
				}
			}
		}

		if (cbMinSingleCountInFour != Constants.MAX_COUNT) {
			int Index = cbMinIndex;

			// 选择最小牌
			for (int i = 0; i < 4; ++i) {
				if (cbOutcardType[i] == cbMinCardType && cbMinSingleCardCount[i] <= cbMinSingleCountInFour
						&& GetCardLogicValue(
								CardTypeResult[cbMinCardType].cbCardData[cbIndex[i]][0]) < GetCardLogicValue(
										CardTypeResult[cbMinCardType].cbCardData[Index][0]))
					Index = cbIndex[i];
			}

			// 对王加一只
			if (cbHandCardCount == 3 && GetCardColor(cbHandCardData[0]) == 0x40
					&& GetCardColor(cbHandCardData[1]) == 0x40) {
				OutCardResult.cbCardCount = 2;
				OutCardResult.cbResultCard[0] = 0x4f;
				OutCardResult.cbResultCard[1] = 0x4e;
				return;
			}
			// 对王
			else if (cbHandCardCount == 2 && GetCardColor(cbHandCardData[0]) == 0x40
					&& GetCardColor(cbHandCardData[1]) == 0x40) {
				OutCardResult.cbCardCount = 2;
				OutCardResult.cbResultCard[0] = 0x4f;
				OutCardResult.cbResultCard[1] = 0x4e;
				return;
			} else {
				// 设置变量
				OutCardResult.cbCardCount = CardTypeResult[cbMinCardType].cbEachHandCardCount[Index];
				Constants.CopyMemory(OutCardResult.cbResultCard, CardTypeResult[cbMinCardType].cbCardData[Index],
						CardTypeResult[cbMinCardType].cbEachHandCardCount[Index]);
				return;
			}
		}
		// 如果只剩炸弹
		else if (CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount > 0) {
			// int Index=0 ;
			// int cbLogicCardValue = GetCardLogicValue(0x4F)+1 ;
			//// 最小炸弹
			// for(int i=0; i<CardTypeResult[CT_BOMB_CARD].cbCardTypeCount; ++i)
			// if(cbLogicCardValue>GetCardLogicValue(CardTypeResult[CT_BOMB_CARD].cbCardData[i][0]))
			// {
			// cbLogicCardValue =
			// GetCardLogicValue(CardTypeResult[CT_BOMB_CARD].cbCardData[i][0])
			// ;
			// Index = i ;
			// }

			// //设置变量
			// OutCardResult.cbCardCount=CardTypeResult[CT_BOMB_CARD].cbEachHandCardCount[Index];
			// CopyMemory(OutCardResult.cbResultCard,CardTypeResult[CT_BOMB_CARD].cbCardData[Index],CardTypeResult[CT_BOMB_CARD].cbEachHandCardCount[Index]*sizeof(int));

			// return ;
		}

		int cbAllSingleCardData[] = new int[Constants.MAX_COUNT], cbAllSingleCardCount;
		cbAllSingleCardCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0, cbAllSingleCardData);

		if (cbAllSingleCardCount > 0) {
			// 如果都没有搜索到就出最小的一张
			if (1 == m_cbUserCardCount[m_wBankerUser]) {
				OutCardResult.cbCardCount = 1;
				OutCardResult.cbResultCard[0] = cbAllSingleCardData[0];
			} else {
				OutCardResult.cbCardCount = 1;
				OutCardResult.cbResultCard[0] = cbAllSingleCardData[cbAllSingleCardCount - 1];
			}
			return;
		}

		// 如果都没有搜索到就出最小的一张
		OutCardResult.cbCardCount = 1;
		OutCardResult.cbResultCard[0] = cbHandCardData[cbHandCardCount - 1];
		return;
	}



	void UpsideOfBankerOutCard(int cbHandCardData[], int cbHandCardCount, int wOutCardUser, int cbTurnCardData[],
			int cbTurnCardCount, tagOutCardResult_Server OutCardResult) {
		// 零下标没用
		tagOutCardTypeResult_Server CardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
		tagOutCardTypeResult_Server.init(CardTypeResult);
		// 出牌类型
		int cbOutCardType = GetCardType(cbTurnCardData, cbTurnCardCount);

		// 地主只有一张，从大到小出牌
		if (m_cbUserCardCount[m_wBankerUser] == 1 && wOutCardUser != m_wBankerUser
				&& Constants.CT_SINGLE == cbOutCardType) {
			int cbSingleCardData[] = new int[Constants.MAX_COUNT];
			int cbSingleCardCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0, cbSingleCardData);

			int wFriendID = (m_wBankerUser + 1) % Constants.DDZ_PLAYER;
			int wMeID = (wFriendID + 1) % Constants.DDZ_PLAYER;

			int cbFriendLargestLogicCard = GetCardLogicValue(m_cbAllCardData[wFriendID][0]);
			int cbMeLargestLogicCard = GetCardLogicValue(cbHandCardData[0]);
			int cbTurnLogicCard = GetCardLogicValue(cbTurnCardData[0]);

			// 只剩单牌(人性化处理)
			if (cbSingleCardCount == cbHandCardCount && cbFriendLargestLogicCard > cbTurnLogicCard
					&& cbMeLargestLogicCard > cbTurnLogicCard) {
				OutCardResult.cbCardCount = 1;
				OutCardResult.cbResultCard[0] = cbHandCardData[0];

				return;
			}
		}

		// 搜索可出牌
		tagOutCardTypeResult_Server BankerOutCardTypeResult[] = new tagOutCardTypeResult_Server[13];
		tagOutCardTypeResult_Server.init(BankerOutCardTypeResult);
		AnalyseOutCardType(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser], BankerOutCardTypeResult);
		AnalyseOutCardType(cbHandCardData, cbHandCardCount, cbTurnCardData, cbTurnCardCount, CardTypeResult);

		// 只剩炸弹
		if (cbHandCardCount == CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[0]
				&& (cbOutCardType < Constants.CT_BOMB_CARD || GetCardLogicValue(
						CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[0][0]) > GetCardLogicValue(
								cbTurnCardData[0]))) {
			OutCardResult.cbCardCount = CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[0];
			Constants.CopyMemory(OutCardResult.cbResultCard, CardTypeResult[Constants.CT_BOMB_CARD].cbCardData,
					OutCardResult.cbCardCount);

			return;
		}
		// 双王炸弹和一手
		else if (cbHandCardCount > 2 && cbHandCardData[0] == 0x4f && cbHandCardData[1] == 0x4e
				&& Constants.CT_ERROR != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)
				&& Constants.CT_FOUR_LINE_TAKE_ONE != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)
				&& Constants.CT_FOUR_LINE_TAKE_TWO != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)) {
			OutCardResult.cbCardCount = 2;
			OutCardResult.cbResultCard[0] = 0x4f;
			OutCardResult.cbResultCard[1] = 0x4e;
			return;
		}

		// 炸弹和一手
		int cbRemainCard[] = new int[Constants.MAX_COUNT], cbRemainCount = 0;
		int cbAllBombCard[] = new int[Constants.MAX_COUNT], cbAllBombCount = 0;
		cbAllBombCount = GetAllBomCard(cbHandCardData, cbHandCardCount, cbAllBombCard, cbAllBombCount);

		// 出炸判断
		if (cbAllBombCount > 0 && m_wBankerUser == wOutCardUser) {
			// 剩余扑克
			Constants.CopyMemory(cbRemainCard, cbHandCardData, cbHandCardCount);
			cbRemainCount = cbHandCardCount;
			RemoveCard(cbAllBombCard, cbAllBombCount, cbRemainCard, cbRemainCount);
			cbRemainCount -= cbAllBombCount;

			if (Constants.CT_ERROR != GetCardType(cbRemainCard, cbRemainCount) || (2 == cbRemainCount
					&& GetCardLogicValue(cbRemainCard[0]) > GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0]))) {
				if ((cbOutCardType < Constants.CT_BOMB_CARD
						|| GetCardLogicValue(cbAllBombCard[0]) > GetCardLogicValue(cbTurnCardData[0]))
						&& (CardTypeResult[cbOutCardType].cbCardTypeCount <= 0
								|| Constants.CT_ERROR != GetCardType(cbRemainCard, cbRemainCount))) {
					// 双王炸弹
					if (GetCardColor(cbAllBombCard[0]) == 0x40) {
						OutCardResult.cbCardCount = 2;
						OutCardResult.cbResultCard[0] = 0x4f;
						OutCardResult.cbResultCard[1] = 0x4e;
						return;
					} else {
						// 分析地主牌
						int cbBankerAllBombCard[] = new int[Constants.MAX_COUNT], cbBankerAllBombCardCount = 0;
						cbBankerAllBombCardCount = GetAllBomCard(m_cbAllCardData[m_wBankerUser],
								m_cbUserCardCount[m_wBankerUser], cbBankerAllBombCard, cbBankerAllBombCardCount);

						if (!CompareCard(cbTurnCardData, cbRemainCard, cbTurnCardCount, cbRemainCount)
								|| cbBankerAllBombCardCount <= 0
								|| GetCardLogicValue(cbAllBombCard[0]) > GetCardLogicValue(cbBankerAllBombCard[0])) {
							OutCardResult.cbCardCount = 4;
							Constants.CopyMemory(OutCardResult.cbResultCard, cbAllBombCard, 4);
							return;
						}
					}
				}
			}
		}

		// 只有一手牌
		if (GetCardType(cbHandCardData, cbHandCardCount) != Constants.CT_FOUR_LINE_TAKE_ONE
				&& GetCardType(cbHandCardData, cbHandCardCount) != Constants.CT_FOUR_LINE_TAKE_TWO
				&& CompareCard(cbTurnCardData, cbHandCardData, cbTurnCardCount, cbHandCardCount)) {
			OutCardResult.cbCardCount = cbHandCardCount;
			Constants.CopyMemory(OutCardResult.cbResultCard, cbHandCardData, cbHandCardCount);

			return;
		}

		// 对牌接牌判断
		if (1 == m_cbUserCardCount[m_wBankerUser] && cbHandCardCount >= 2 && cbOutCardType == Constants.CT_DOUBLE) {
			tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();
			// ZeroMemory(AnalyseResult,sizeof(AnalyseResult));

			// 分析扑克
			AnalysebCardData(cbHandCardData, cbHandCardCount, AnalyseResult);

			// 对牌判断
			if (cbHandCardCount == (AnalyseResult.cbDoubleCount * 2 + AnalyseResult.cbThreeCount * 3
					+ AnalyseResult.cbFourCount * 4)
					|| cbHandCardCount == (AnalyseResult.cbDoubleCount * 2 + AnalyseResult.cbThreeCount * 3
							+ AnalyseResult.cbFourCount * 4 + 1)) {
				// 出对判断
				for (int nIndex = AnalyseResult.cbDoubleCount - 1; nIndex >= 0; --nIndex) {
					if (GetCardLogicValue(AnalyseResult.cbDoubleCardData[nIndex * 2]) > GetCardLogicValue(
							cbTurnCardData[0])) {
						OutCardResult.cbCardCount = 2;
						OutCardResult.cbResultCard[0] = AnalyseResult.cbDoubleCardData[nIndex * 2];
						OutCardResult.cbResultCard[1] = AnalyseResult.cbDoubleCardData[nIndex * 2 + 1];
						return;
					}
				}

				// 出炸判断
				if (AnalyseResult.cbFourCount > 0) {
					// 最小炸弹
					int cbLestBombIndex = AnalyseResult.cbFourCount - 1;

					OutCardResult.cbCardCount = 4;
					OutCardResult.cbResultCard[0] = AnalyseResult.cbFourCardData[cbLestBombIndex * 4];
					OutCardResult.cbResultCard[1] = AnalyseResult.cbFourCardData[cbLestBombIndex * 4 + 1];
					OutCardResult.cbResultCard[2] = AnalyseResult.cbFourCardData[cbLestBombIndex * 4 + 2];
					OutCardResult.cbResultCard[3] = AnalyseResult.cbFourCardData[cbLestBombIndex * 4 + 3];

					return;
				}

			}

			// 分析对家
			if (wOutCardUser != m_wBankerUser) {
				tagAnalyseResult_Server FriendAnalyseResult = new tagAnalyseResult_Server();

				// 分析扑克
				AnalysebCardData(m_cbAllCardData[wOutCardUser], m_cbUserCardCount[wOutCardUser], FriendAnalyseResult);

				// 对牌判断
				if (m_cbUserCardCount[wOutCardUser] == (FriendAnalyseResult.cbDoubleCount * 2
						+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4)
						|| m_cbUserCardCount[wOutCardUser] == (FriendAnalyseResult.cbDoubleCount * 2
								+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4 + 1)) {
					return;
				}

				// 零下标没用
				tagOutCardTypeResult_Server FriendCardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
				tagOutCardTypeResult_Server.init(FriendCardTypeResult);
				// ZeroMemory(FriendCardTypeResult,sizeof(FriendCardTypeResult));

				AnalyseOutCardType(m_cbAllCardData[wOutCardUser], m_cbUserCardCount[wOutCardUser],
						FriendCardTypeResult);

				for (int cbLineCardIdx = 0; cbLineCardIdx < FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbCardTypeCount; ++cbLineCardIdx) {
					// 剩余扑克
					int cbRemainCardData[] = new int[Constants.MAX_COUNT], cbRemainCardCount = 0;

					cbRemainCardCount = m_cbUserCardCount[wOutCardUser];
					Constants.CopyMemory(cbRemainCardData, m_cbAllCardData[wOutCardUser], cbRemainCardCount);
					RemoveCard(FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbCardData[cbLineCardIdx],
							FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbEachHandCardCount[cbLineCardIdx],
							cbRemainCardData, cbRemainCardCount);

					cbRemainCardCount -= FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbEachHandCardCount[cbLineCardIdx];

					// 分析扑克
					AnalysebCardData(cbRemainCardData, cbRemainCardCount, FriendAnalyseResult);

					// 对牌判断
					if (cbRemainCardCount == (FriendAnalyseResult.cbDoubleCount * 2
							+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4)
							|| cbRemainCardCount == (FriendAnalyseResult.cbDoubleCount * 2
									+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4 + 1)) {
						return;
					}
				}

				for (int cbLineCardIdx = 0; cbLineCardIdx < FriendCardTypeResult[Constants.CT_DOUBLE_LINE].cbCardTypeCount; ++cbLineCardIdx) {
					// 剩余扑克
					int cbRemainCardData[] = new int[Constants.MAX_COUNT], cbRemainCardCount = 0;

					cbRemainCardCount = m_cbUserCardCount[wOutCardUser];
					Constants.CopyMemory(cbRemainCardData, m_cbAllCardData[wOutCardUser], cbRemainCardCount);
					RemoveCard(FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbCardData[cbLineCardIdx],
							FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbEachHandCardCount[cbLineCardIdx],
							cbRemainCardData, cbRemainCardCount);

					cbRemainCardCount -= FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbEachHandCardCount[cbLineCardIdx];

					// 分析扑克
					AnalysebCardData(cbRemainCardData, cbRemainCardCount, FriendAnalyseResult);

					// 对牌判断
					if (cbRemainCardCount == (FriendAnalyseResult.cbDoubleCount * 2
							+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4)
							|| cbRemainCardCount == (FriendAnalyseResult.cbDoubleCount * 2
									+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4 + 1)) {
						return;
					}
				}

			}
		}

		// 对家可否出完
		if (m_wBankerUser != wOutCardUser && !CompareCard(cbTurnCardData, m_cbAllCardData[m_wBankerUser],
				cbTurnCardCount, m_cbUserCardCount[m_wBankerUser])) {
			// 庄家扑克
			boolean bBankerCanOut = false;
			tagOutCardTypeResult_Server BankerOutCardResult[] = new tagOutCardTypeResult_Server[12 + 1];
			tagOutCardTypeResult_Server.init(BankerOutCardResult);
			// ZeroMemory(BankerOutCardResult,sizeof(BankerOutCardResult));

			// 分析扑克
			AnalyseOutCardType(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser], cbTurnCardData,
					cbTurnCardCount, BankerOutCardResult);
			for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType)
				if (BankerOutCardResult[cbCardType].cbCardTypeCount > 0)
					bBankerCanOut = true;

			if (!bBankerCanOut) {
				// 对家ID
				int wFriendChairID = (m_wBankerUser + 1) % Constants.DDZ_PLAYER;

				// 分析扑克
				tagOutCardTypeResult_Server FriendCardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
				tagOutCardTypeResult_Server.init(FriendCardTypeResult);
				// ZeroMemory(FriendCardTypeResult,sizeof(FriendCardTypeResult));
				AnalyseOutCardType(m_cbAllCardData[wFriendChairID], m_cbUserCardCount[wFriendChairID],
						FriendCardTypeResult);

				for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType)
					if (FriendCardTypeResult[cbCardType].cbCardTypeCount > 0) {
						for (int lIndex = 0; lIndex < FriendCardTypeResult[cbCardType].cbCardTypeCount; ++lIndex) {
							if (TestOutAllCard(wFriendChairID, FriendCardTypeResult[cbCardType].cbCardData[lIndex],
									FriendCardTypeResult[cbCardType].cbEachHandCardCount[lIndex], true)) {
								// 不压对家
								return;
							}
						}
					}
			}
		}

		// 放走对家
		if (GetCardType(m_cbAllCardData[(m_wBankerUser + 1) % Constants.DDZ_PLAYER],
				m_cbUserCardCount[(m_wBankerUser + 1) % Constants.DDZ_PLAYER]) == GetCardType(cbTurnCardData,
						cbTurnCardCount)
				&& CompareCard(cbTurnCardData, m_cbAllCardData[(m_wBankerUser + 1) % Constants.DDZ_PLAYER],
						cbTurnCardCount, m_cbUserCardCount[(m_wBankerUser + 1) % Constants.DDZ_PLAYER])
				&& !CompareCard(cbTurnCardData, m_cbAllCardData[m_wBankerUser], cbTurnCardCount,
						m_cbUserCardCount[m_wBankerUser]))
			return;

		if (CompareCard(cbTurnCardData, m_cbAllCardData[(m_wBankerUser + 1) % Constants.DDZ_PLAYER], cbTurnCardCount,
				m_cbUserCardCount[(m_wBankerUser + 1) % Constants.DDZ_PLAYER])
				&& !CompareCard(cbTurnCardData, m_cbAllCardData[m_wBankerUser], cbTurnCardCount,
						m_cbUserCardCount[m_wBankerUser]))
			return;

		// 判断可否出完
		int cbSingleCardCount = Constants.MAX_COUNT + Constants.CT_MISSILE_CARD;
		boolean bFindBestCard = false;
		for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType)
			if (CardTypeResult[cbCardType].cbCardTypeCount > 0) {
				for (int lIndex = 0; lIndex < CardTypeResult[cbCardType].cbCardTypeCount; ++lIndex) {
					int wMeChairID = (m_wBankerUser + 2) % Constants.DDZ_PLAYER;

					if (TestOutAllCard(wMeChairID, CardTypeResult[cbCardType].cbCardData[lIndex],
							CardTypeResult[cbCardType].cbEachHandCardCount[lIndex], false)) {
						// 计算单牌
						int cbTmpSingleCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
								CardTypeResult[cbCardType].cbCardData[lIndex],
								CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);

						// 结果判断
						if (cbTmpSingleCount >= Constants.MAX_COUNT)
							continue;

						// 炸弹优先级排后
						int cbBombCardType = GetCardType(CardTypeResult[cbCardType].cbCardData[lIndex],
								CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);
						if (cbBombCardType == Constants.CT_BOMB_CARD)
							cbTmpSingleCount += 4;
						else if (cbBombCardType == Constants.CT_MISSILE_CARD)
							cbTmpSingleCount += 5;

						//// 改变权值
						// if (cbBombCardType != CT_ERROR) cbTmpSingleCount +=
						//// cbBombCardType ;

						// 不出炸弹
						// int cbWantOutCardType =
						// GetCardType(CardTypeResult[cbCardType].cbCardData[lIndex],
						// CardTypeResult[cbCardType].cbEachHandCardCount[lIndex])
						// ;
						// if (CardTypeResult[cbOutCardType].cbCardTypeCount > 0
						// &&
						// cbOutCardType < CT_BOMB_CARD && cbWantOutCardType >=
						// CT_BOMB_CARD)
						// continue ;

						if (cbTmpSingleCount <= cbSingleCardCount) {
							// 设置变量
							OutCardResult.cbCardCount = CardTypeResult[cbCardType].cbEachHandCardCount[lIndex];
							Constants.CopyMemory(OutCardResult.cbResultCard,
									CardTypeResult[cbCardType].cbCardData[lIndex],
									CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);
							cbSingleCardCount = cbTmpSingleCount;

							bFindBestCard = true;
						}
					}
				}
			}
		// 直接返回
		if (bFindBestCard)
			return;

		// 如果庄家没有此牌型了则不压对家牌
		if (m_cbUserCardCount[m_wBankerUser] <= 5 && wOutCardUser != m_wBankerUser
				&& (BankerOutCardTypeResult[cbOutCardType].cbCardTypeCount == 0 || GetCardLogicValue(
						BankerOutCardTypeResult[cbOutCardType].cbCardData[0][0]) <= GetCardLogicValue(
								cbTurnCardData[0]))
				&& CardTypeResult[cbOutCardType].cbEachHandCardCount[0] != cbHandCardCount)// 不能一次出完
		{
			// 放弃出牌
			return;
		}

		// 下家为地主，而且地主扑克少于5张
		if (m_cbUserCardCount[m_wBankerUser] <= 5 && CardTypeResult[cbOutCardType].cbCardTypeCount > 0
				&& cbOutCardType != Constants.CT_BOMB_CARD
				&& ((GetCardLogicValue(cbTurnCardData[0]) < 12 && wOutCardUser != m_wBankerUser
						&& BankerOutCardTypeResult[cbOutCardType].cbCardTypeCount > 0) || // 对家出牌
						(wOutCardUser == m_wBankerUser)))// 地主出牌
		{
			// 防止三带等带大牌出去
			int Index = cbOutCardType == Constants.CT_SINGLE ? 0 : CardTypeResult[cbOutCardType].cbCardTypeCount - 1;
			// 寻找可以压住地主的最小一手牌
			int cbThisOutTypeMinSingleCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
					CardTypeResult[cbOutCardType].cbCardData[0], CardTypeResult[cbOutCardType].cbEachHandCardCount[0]);
			int cbBestIndex = 255;
			for (int i = 0; i < CardTypeResult[cbOutCardType].cbCardTypeCount; ++i) {
				int cbTmpSingleCardCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
						CardTypeResult[cbOutCardType].cbCardData[i],
						CardTypeResult[cbOutCardType].cbEachHandCardCount[i]);
				if ((BankerOutCardTypeResult[cbOutCardType].cbCardTypeCount > 0
						&& GetCardLogicValue(CardTypeResult[cbOutCardType].cbCardData[i][0]) >= GetCardLogicValue(
								BankerOutCardTypeResult[cbOutCardType].cbCardData[0][0])
						|| BankerOutCardTypeResult[cbOutCardType].cbCardTypeCount == 0)
						&& cbTmpSingleCardCount <= cbThisOutTypeMinSingleCount) {
					cbBestIndex = i;
					cbThisOutTypeMinSingleCount = cbTmpSingleCardCount;
				}

				if ((BankerOutCardTypeResult[cbOutCardType].cbCardTypeCount > 0
						&& GetCardLogicValue(CardTypeResult[cbOutCardType].cbCardData[i][0]) >= GetCardLogicValue(
								BankerOutCardTypeResult[cbOutCardType].cbCardData[0][0])
						|| BankerOutCardTypeResult[cbOutCardType].cbCardTypeCount == 0))
					Index = i;
				else
					break;
			}

			if (cbBestIndex != 255) {
				OutCardResult.cbCardCount = CardTypeResult[cbOutCardType].cbEachHandCardCount[cbBestIndex];
				Constants.CopyMemory(OutCardResult.cbResultCard, CardTypeResult[cbOutCardType].cbCardData[cbBestIndex],
						OutCardResult.cbCardCount);
			} else {
				OutCardResult.cbCardCount = CardTypeResult[cbOutCardType].cbEachHandCardCount[Index];
				Constants.CopyMemory(OutCardResult.cbResultCard, CardTypeResult[cbOutCardType].cbCardData[Index],
						OutCardResult.cbCardCount);
			}

			return;
		}

		// 单牌顶牌
		if (Constants.CT_SINGLE == cbOutCardType && CardTypeResult[cbOutCardType].cbCardTypeCount > 0) {
			int cbMeSingleCardData[] = new int[Constants.MAX_COUNT], cbMeSingleCardCount;
			int cbBankerSingleCardData[] = new int[Constants.MAX_COUNT], cbBankerSingleCardCount;

			// 获取单牌
			cbMeSingleCardCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0, cbMeSingleCardData);
			cbBankerSingleCardCount = AnalyseSinleCardCount(m_cbAllCardData[m_wBankerUser],
					m_cbUserCardCount[m_wBankerUser], null, 0, cbBankerSingleCardData);

			// 地主还有小牌
			if (cbBankerSingleCardCount > 0 && cbMeSingleCardCount > 0
					&& GetCardLogicValue(cbBankerSingleCardData[cbBankerSingleCardCount - 1]) <= 10) {
				// 拦截两张
				if (cbBankerSingleCardCount >= 2
						&& GetCardValue(cbBankerSingleCardData[cbBankerSingleCardCount - 2]) <= 10) {
					for (int nMeIndex = cbMeSingleCardCount - 1; nMeIndex >= 0; --nMeIndex)
						if (GetCardLogicValue(cbMeSingleCardData[nMeIndex]) > GetCardLogicValue(cbTurnCardData[0])
								&& GetCardLogicValue(cbMeSingleCardData[nMeIndex]) >= GetCardLogicValue(
										cbBankerSingleCardData[cbBankerSingleCardCount - 2])
								&& GetCardLogicValue(cbMeSingleCardData[nMeIndex]) <= 15) {
							OutCardResult.cbCardCount = 1;
							OutCardResult.cbResultCard[0] = cbMeSingleCardData[nMeIndex];

							return;
						}
				}

				// 拦截一张
				for (int nMeIndex = cbMeSingleCardCount - 1; nMeIndex >= 0; --nMeIndex)
					if (GetCardLogicValue(cbMeSingleCardData[nMeIndex]) > GetCardLogicValue(cbTurnCardData[0])
							&& GetCardLogicValue(cbMeSingleCardData[nMeIndex]) >= GetCardLogicValue(
									cbBankerSingleCardData[cbBankerSingleCardCount - 1])
							&& GetCardLogicValue(cbMeSingleCardData[nMeIndex]) <= 15) {
						OutCardResult.cbCardCount = 1;
						OutCardResult.cbResultCard[0] = cbMeSingleCardData[nMeIndex];

						return;
					}
			}
		}

		// 取出四个最小单牌
		int cbMinSingleCardCount[] = new int[4];
		cbMinSingleCardCount[0] = Constants.MAX_COUNT;
		cbMinSingleCardCount[1] = Constants.MAX_COUNT;
		cbMinSingleCardCount[2] = Constants.MAX_COUNT;
		cbMinSingleCardCount[3] = Constants.MAX_COUNT;
		int cbIndex[] = { 0, 0, 0, 0 };
		int cbMinSingleCountInFour = Constants.MAX_COUNT;

		// 可出扑克（这里已经过滤掉炸弹了）
		tagOutCardTypeResult_Server CanOutCard = CardTypeResult[cbOutCardType];

		for (int i = 0; i < CanOutCard.cbCardTypeCount; ++i) {
			// 最小单牌
			int cbTmpCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, CanOutCard.cbCardData[i],
					CanOutCard.cbEachHandCardCount[i]);
			int cbMaxValue = 0;
			int Index = 0;

			// 搜索cbMinSingleCardCount[4]的最大值
			for (int j = 0; j < 4; ++j) {
				if (cbMinSingleCardCount[j] >= cbTmpCount) {
					cbMinSingleCardCount[j] = cbTmpCount;
					cbIndex[j] = i;
					break;
				}
			}

		}

		for (int i = 0; i < 4; ++i)
			if (cbMinSingleCountInFour > cbMinSingleCardCount[i])
				cbMinSingleCountInFour = cbMinSingleCardCount[i];

		// 原始单牌数
		int cbOriginSingleCardCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0);

		// 分析地主对牌
		int cbBankerDoubleCardData[] = new int[Constants.MAX_COUNT], cbBankerDoubleCardCount = 0;
		cbBankerDoubleCardCount = GetAllDoubleCard(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser], cbBankerDoubleCardData,
				cbBankerDoubleCardCount);

		// 朋友出牌
		boolean bFriendOut = m_wBankerUser != wOutCardUser;
		if (bFriendOut) {
			// 不拦截朋友最后一手牌
			if (GetCardType(m_cbAllCardData[(1 + m_wBankerUser) % Constants.DDZ_PLAYER],
					m_cbUserCardCount[(1 + m_wBankerUser) % Constants.DDZ_PLAYER]) != Constants.CT_ERROR)
				return;

			// 在上面的TestOutAllCard中已对可出炸弹情况分析过
			if (CanOutCard.cbCardTypeCount > 0 && CanOutCard.cbCardType < Constants.CT_BOMB_CARD) {
				// 分析地主单牌
				int cbBankerSingleCardData[] = new int[Constants.MAX_COUNT];
				int cbBankerSingleCardCount = AnalyseSinleCardCount(m_cbAllCardData[m_wBankerUser],
						m_cbUserCardCount[m_wBankerUser], null, 0, cbBankerSingleCardData);
				int cbBankerSingleCardLogic = 0;

				if (cbBankerSingleCardCount >= 2
						&& GetCardLogicValue(cbBankerSingleCardData[cbBankerSingleCardCount - 2]) <= 10)
					cbBankerSingleCardLogic = GetCardLogicValue(cbBankerSingleCardData[cbBankerSingleCardCount - 2]);
				else if (cbBankerSingleCardCount >= 2
						&& GetCardLogicValue(cbBankerSingleCardData[cbBankerSingleCardCount - 1]) <= 10)
					cbBankerSingleCardLogic = GetCardLogicValue(cbBankerSingleCardData[cbBankerSingleCardCount - 1]);
				else if (cbBankerSingleCardCount > 0 && GetCardLogicValue(cbBankerSingleCardData[0]) <= 10)
					cbBankerSingleCardLogic = GetCardLogicValue(cbBankerSingleCardData[0]);

				int cbMinLogicCardValue = GetCardLogicValue(0x4F) + 1;
				boolean bFindCard = false;
				int cbCanOutIndex = 0;
				for (int i = 0; i < 4; ++i) {
					int Index = cbIndex[i];

					// 三带，和连牌不接对家牌
					if (CanOutCard.cbCardType >= Constants.CT_THREE
							&& CanOutCard.cbCardType <= Constants.CT_MISSILE_CARD
							&& GetCardLogicValue(CanOutCard.cbCardData[Index][0]) >= 7
							&& CanOutCard.cbEachHandCardCount[Index] <= 5)
						continue;

					// 单牌拦截
					boolean bCanOut = false;
					if (cbOutCardType == Constants.CT_SINGLE && cbBankerSingleCardCount > 0
							&& GetCardLogicValue(CanOutCard.cbCardData[Index][0]) >= cbBankerSingleCardLogic
							&& GetCardLogicValue(cbTurnCardData[0]) < 14
							&& cbMinSingleCardCount[i] < cbOriginSingleCardCount && GetCardLogicValue(
									m_cbAllCardData[m_wBankerUser][0]) > GetCardLogicValue(cbTurnCardData[0]))
						bCanOut = true;

					// 拦截对牌
					// if (cbOutCardType == CT_DOUBLE && cbBankerDoubleCardCount
					// > 0 &&
					// GetCardLogicValue(cbBankerDoubleCardData[cbBankerDoubleCardCount-1])
					// < 10 &&
					// GetCardLogicValue(CanOutCard.cbCardData[Index][0]) <
					// GetCardLogicValue(cbBankerDoubleCardData[cbBankerDoubleCardCount-1])
					// &&
					// GetCardLogicValue(CanOutCard.cbCardData[0][0]) >= 10 &&
					// GetCardLogicValue(CanOutCard.cbCardData[0][0]) < 14)
					// continue ;

					// 小于J的牌，或者小于K而且是散牌
					if (bCanOut || ((cbMinSingleCardCount[i] < cbOriginSingleCardCount + 3
							&& (cbMinSingleCardCount[i] <= cbMinSingleCountInFour
									|| cbMinSingleCardCount[i] <= cbMinSingleCountInFour + 1
											&& CanOutCard.cbCardType >= Constants.CT_THREE_LINE_TAKE_ONE
											&& CanOutCard.cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO)
							&& (GetCardLogicValue(CanOutCard.cbCardData[Index][0]) <= 11
									|| (cbMinSingleCardCount[i] < cbOriginSingleCardCount)
											&& GetCardLogicValue(CanOutCard.cbCardData[Index][0]) <= 13))
							&& cbMinLogicCardValue > GetCardLogicValue(CanOutCard.cbCardData[Index][0])
							&& cbHandCardCount > 5)) {
						// 搜索有没有大牌（针对飞机带翅膀后面的带牌）
						boolean bNoLargeCard = true;
						for (int k = 3; k < CanOutCard.cbEachHandCardCount[Index]; ++k) {
							// 有大牌而且不能一次出完
							if (GetCardLogicValue(CanOutCard.cbCardData[Index][k]) >= 15
									&& CanOutCard.cbEachHandCardCount[Index] != cbHandCardCount)
								bNoLargeCard = false;
						}
						if (bNoLargeCard) {
							bFindCard = true;
							cbCanOutIndex = Index;
							cbMinLogicCardValue = GetCardLogicValue(CanOutCard.cbCardData[Index][0]);
						}
					} else if (cbHandCardCount < 5 && cbMinSingleCardCount[i] < cbOriginSingleCardCount + 4
							&& cbMinSingleCardCount[i] <= cbMinSingleCountInFour
							&& cbMinLogicCardValue > GetCardLogicValue(CanOutCard.cbCardData[Index][0])) {
						// 能出王打自家的2
						if (GetCardLogicValue(CanOutCard.cbCardData[Index][0]) >= 16
								&& GetCardLogicValue(cbTurnCardData[0]) >= 15)
							continue;

						bFindCard = true;
						cbCanOutIndex = Index;
						cbMinLogicCardValue = GetCardLogicValue(CanOutCard.cbCardData[Index][0]);
					}
				}

				if (bFindCard) {

					// 设置变量
					OutCardResult.cbCardCount = CanOutCard.cbEachHandCardCount[cbCanOutIndex];
					Constants.CopyMemory(OutCardResult.cbResultCard, CanOutCard.cbCardData[cbCanOutIndex],
							CanOutCard.cbEachHandCardCount[cbCanOutIndex]);

					return;
				}
				// 手上少于五张牌
				else if (cbHandCardCount <= 5) {
					int cbMinLogicCard = GetCardLogicValue(0x4f) + 1;
					int cbCanOutIndex1 = 0;
					for (int i = 0; i < 4; ++i)
						if (cbMinSingleCardCount[i] < Constants.MAX_COUNT
								&& cbMinSingleCardCount[i] <= cbMinSingleCountInFour
								&& cbMinLogicCard > GetCardLogicValue(CanOutCard.cbCardData[cbIndex[i]][0])
								&& GetCardLogicValue(CanOutCard.cbCardData[cbIndex[i]][0]) <= 14) {
							cbMinLogicCard = GetCardLogicValue(CanOutCard.cbCardData[cbIndex[i]][0]);
							cbCanOutIndex1 = cbIndex[i];
						}

					if (cbMinLogicCard != (GetCardLogicValue(0x4f) + 1)) {
						// 设置变量
						OutCardResult.cbCardCount = CanOutCard.cbEachHandCardCount[cbCanOutIndex1];
						Constants.CopyMemory(OutCardResult.cbResultCard, CanOutCard.cbCardData[cbCanOutIndex1],
								CanOutCard.cbEachHandCardCount[cbCanOutIndex1]);

						return;
					}
				}

				return;
			} else {
				return;
			}

		}
		// 地主出牌
		else {
			if (CanOutCard.cbCardTypeCount > 0) {
				int cbMinLogicCardValue = GetCardLogicValue(0x4F) + 1;
				boolean bFindCard = false;
				int cbCanOutIndex = 0;
				for (int i = 0; i < 4; ++i) {
					int Index = cbIndex[i];

					if ((cbMinSingleCardCount[i] < cbOriginSingleCardCount + 4)
							&& (cbMinSingleCardCount[i] <= cbMinSingleCountInFour
									|| cbMinSingleCardCount[i] <= cbMinSingleCountInFour + 1
											&& CanOutCard.cbCardType >= Constants.CT_THREE_LINE_TAKE_ONE
											&& CanOutCard.cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO)
							&& cbMinLogicCardValue > GetCardLogicValue(CanOutCard.cbCardData[Index][0])) {
						// 针对大牌
						boolean bNoLargeCard = true;

						// 当地主手上牌数大于4，而且地主出的是小于K的牌而且不是地主手上的最大牌时，不能出2去打
						if (m_cbUserCardCount[m_wBankerUser] >= 4 && cbHandCardCount >= 5
								&& CanOutCard.cbEachHandCardCount[Index] >= 2
								&& GetCardLogicValue(CanOutCard.cbCardData[Index][0]) >= 15
								&& GetCardLogicValue(cbTurnCardData[0]) < 13
								&& GetCardLogicValue(cbTurnCardData[0]) < GetCardLogicValue(
										m_cbAllCardData[m_wBankerUser][0])
								&& CanOutCard.cbEachHandCardCount[Index] != cbHandCardCount)
							bNoLargeCard = false;

						// 搜索有没有大牌（针对飞机带翅膀后面的带牌）
						for (int k = 3; k < CanOutCard.cbEachHandCardCount[Index]; ++k) {
							if (GetCardLogicValue(CanOutCard.cbCardData[Index][k]) >= 15
									&& CanOutCard.cbEachHandCardCount[Index] != cbHandCardCount)
								bNoLargeCard = false;
						}
						if (bNoLargeCard) {
							bFindCard = true;
							cbCanOutIndex = Index;
							cbMinLogicCardValue = GetCardLogicValue(CanOutCard.cbCardData[Index][0]);
						}
					}
				}

				if (bFindCard) {
					// 地主的最大牌
					int cbLargestLogicCard = GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0]);
					boolean bCanOut = true;

					// 王只压2
					if (GetCardLogicValue(cbTurnCardData[0]) < cbLargestLogicCard) {
						if (GetCardColor(CanOutCard.cbCardData[cbCanOutIndex][0]) == 0x40
								&& GetCardLogicValue(cbTurnCardData[0]) <= 14 && cbHandCardCount > 5) {
							bCanOut = false;
						}
					}
					// 双王判断
					if (GetCardLogicValue(CanOutCard.cbCardData[cbCanOutIndex][0]) >= 16 && cbHandCardCount >= 2
							&& cbHandCardData[0] == 0x4F && cbHandCardData[1] == 0x4E) {
						boolean bOutMissileCard = false;
						// 一手牌和一个炸弹
						int cbRemainCardData[] = new int[20], cbRemainCardCount = cbHandCardCount;
						Constants.CopyMemory(cbRemainCardData, cbHandCardData, cbHandCardCount);
						RemoveCard(cbRemainCardData, 2, cbRemainCardData, cbRemainCardCount);
						cbRemainCardCount -= 2;
						if (Constants.CT_ERROR != GetCardType(cbRemainCardData, cbRemainCardCount))
							bOutMissileCard = true;

						// 只剩少量牌
						int cbRemainLargestCard = GetCardLogicValue(cbRemainCardData[0]);
						if (cbRemainCardCount < 5 && cbRemainCardCount > 0
								&& GetCardLogicValue(cbRemainCardData[0]) >= 14)
							bOutMissileCard = true;

						// 炸后单牌数
						int cbSingleCardCount1 = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
								CanOutCard.cbCardData[cbCanOutIndex], CanOutCard.cbEachHandCardCount[cbCanOutIndex]);
						if (cbSingleCardCount1 <= 1 && GetCardLogicValue(cbRemainCardData[0]) >= 11)
							bOutMissileCard = true;

						// 还有小牌
						if (GetCardLogicValue(cbRemainCardData[0]) <= 10
								&& Constants.CT_ERROR == GetCardType(cbRemainCardData, cbRemainCardCount)
								&& GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0]) > 10)
							bOutMissileCard = false;

						// 火箭扑克
						if (bOutMissileCard) {
							// 优先其他炸弹
							int cbIndex1 = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount - 1;

							OutCardResult.cbCardCount = CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[cbIndex1];
							Constants.CopyMemory(OutCardResult.cbResultCard,
									CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[cbIndex1],
									OutCardResult.cbCardCount);
							return;
						}
					}

					if (bCanOut) {
						// 设置变量
						OutCardResult.cbCardCount = CanOutCard.cbEachHandCardCount[cbCanOutIndex];
						Constants.CopyMemory(OutCardResult.cbResultCard, CanOutCard.cbCardData[cbCanOutIndex],
								CanOutCard.cbEachHandCardCount[cbCanOutIndex]);

						return;
					}
				}

				if (cbOutCardType == Constants.CT_SINGLE) {
					// 地主的最大牌
					int cbLargestLogicCard = GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0]);

					if (GetCardLogicValue(cbTurnCardData[0]) == 14
							|| GetCardLogicValue(cbTurnCardData[0]) >= cbLargestLogicCard
							|| (GetCardLogicValue(cbTurnCardData[0]) < cbLargestLogicCard - 1)
							|| m_cbUserCardCount[m_wBankerUser] <= 5) {
						// 取一张大于等于2而且要比地主出的牌大的牌，
						int cbIndex1 = Constants.MAX_COUNT;
						for (int i = 0; i < cbHandCardCount; ++i)
							if (GetCardLogicValue(cbHandCardData[i]) > GetCardLogicValue(cbTurnCardData[0])
									&& GetCardLogicValue(cbHandCardData[i]) >= 15) {
								cbIndex1 = i;
							}
						if (cbIndex1 != Constants.MAX_COUNT) {
							// 设置变量
							OutCardResult.cbCardCount = 1;
							OutCardResult.cbResultCard[0] = cbHandCardData[cbIndex1];

							return;
						}
					}
				}
			}

			// 还要考虑炸弹
			if (CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount > 0 || (Constants.NORMAL_COUNT == cbHandCardCount
					&& Constants.NORMAL_COUNT == m_cbUserCardCount[(m_wBankerUser + 1) % Constants.DDZ_PLAYER])) {
				tagOutCardTypeResult_Server BomCard = CardTypeResult[Constants.CT_BOMB_CARD];
				int cbMinLogicValue = GetCardLogicValue(BomCard.cbCardData[0][0]);
				int Index = 0;
				for (int i = 0; i < BomCard.cbCardTypeCount; ++i) {
					if (cbMinLogicValue > GetCardLogicValue(BomCard.cbCardData[i][0])) {
						cbMinLogicValue = GetCardLogicValue(BomCard.cbCardData[i][0]);
						Index = i;
					}
				}

				boolean bOutBomb = false;

				// 春天判断
				if (Constants.NORMAL_COUNT == cbHandCardCount
						&& Constants.NORMAL_COUNT == m_cbUserCardCount[(m_wBankerUser + 1) % Constants.DDZ_PLAYER]
						&& Constants.CT_ERROR != GetCardType(m_cbAllCardData[m_wBankerUser],
								m_cbUserCardCount[m_wBankerUser]))
					bOutBomb = true;

				// 一手牌和一个炸弹
				int cbRemainCardData[] = new int[20], cbRemainCardCount = cbHandCardCount;
				Constants.CopyMemory(cbRemainCardData, cbHandCardData, cbHandCardCount);
				RemoveCard(BomCard.cbCardData[Index], BomCard.cbEachHandCardCount[Index], cbRemainCardData,
						cbRemainCardCount);
				cbRemainCardCount -= BomCard.cbEachHandCardCount[Index];
				if (Constants.CT_ERROR != GetCardType(cbRemainCardData, cbRemainCardCount))
					bOutBomb = true;

				// 炸后单牌数
				int cbSingleCardCount1 = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
						BomCard.cbCardData[Index], BomCard.cbEachHandCardCount[Index]);
				if (cbSingleCardCount1 == 0 && GetCardLogicValue(cbRemainCardData[0]) > GetCardLogicValue(
						m_cbAllCardData[m_wBankerUser][0]))
					bOutBomb = true;

				// 只剩一手
				int cbRemainCardType = GetCardType(m_cbAllCardData[wOutCardUser], m_cbUserCardCount[wOutCardUser]);
				if (cbRemainCardType > Constants.CT_ERROR && cbRemainCardType < Constants.CT_FOUR_LINE_TAKE_ONE
						&& GetCardLogicValue(m_cbAllCardData[wOutCardUser][0]) < 15 && cbSingleCardCount1 < 2
						&& (GetCardLogicValue(cbRemainCardData[0]) >= GetCardLogicValue(
								m_cbAllCardData[m_wBankerUser][0])))
					bOutBomb = true;

				// 只剩少量牌
				int cbRemainLargestCard = GetCardLogicValue(cbRemainCardData[0]);
				if (cbRemainCardCount < 5 && cbRemainCardCount > 0
						&& (cbRemainLargestCard != GetCardLogicValue(BomCard.cbCardData[Index][0]))
						&& cbRemainLargestCard > GetCardLogicValue(m_cbAllCardData[wOutCardUser][0])
						&& cbRemainLargestCard > 14)
					bOutBomb = true;

				// 分析扑克
				tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();
				AnalysebCardData(cbRemainCardData, cbRemainCardCount, AnalyseResult);

				if (m_cbUserCardCount[m_wBankerUser] == 1 && (AnalyseResult.cbDoubleCount * 2
						+ AnalyseResult.cbThreeCount * 3 + AnalyseResult.cbFourCount * 4 + 1 >= cbRemainCardCount))
					bOutBomb = true;

				// 设置变量
				if (bOutBomb) {
					OutCardResult.cbCardCount = BomCard.cbEachHandCardCount[Index];
					Constants.CopyMemory(OutCardResult.cbResultCard, BomCard.cbCardData[Index],
							BomCard.cbEachHandCardCount[Index]);
				}

				return;
			}

			return;
		}
	}

	// 地主下家（先出牌）
	void UndersideOfBankerOutCard(int cbHandCardData[], int cbHandCardCount, int wMeChairID,
			tagOutCardResult_Server OutCardResult) {
		// 零下标没用
		tagOutCardTypeResult_Server CardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
		tagOutCardTypeResult_Server.init(CardTypeResult);
		// Constants.ZeroMemory(CardTypeResult,sizeof(CardTypeResult));

		// 初始变量
		// Constants.ZeroMemory(OutCardResult,sizeof(OutCardResult));

		int cbLineCard[] = new int[Constants.MAX_COUNT];
		int cbThreeLineCard[] = new int[Constants.MAX_COUNT];
		int cbDoubleLineCard[] = new int[Constants.MAX_COUNT];
		int cbLineCardCount = 0;
		int cbThreeLineCardCount = 0;
		int cbDoubleLineCount = 0;
		cbLineCardCount = GetAllLineCard(cbHandCardData, cbHandCardCount, cbLineCard, cbLineCardCount);
		cbThreeLineCardCount = GetAllThreeCard(cbHandCardData, cbHandCardCount, cbThreeLineCard, cbThreeLineCardCount);
		cbDoubleLineCount = GetAllDoubleCard(cbHandCardData, cbHandCardCount, cbDoubleLineCard, cbDoubleLineCount);

		// 判断可否出完
		int cbSingleCardCount = Constants.MAX_COUNT + Constants.CT_MISSILE_CARD;
		boolean bFindBestCard = false;
		AnalyseOutCardType(cbHandCardData, cbHandCardCount, CardTypeResult);
		for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType)
			if (CardTypeResult[cbCardType].cbCardTypeCount > 0) {
				for (int lIndex = 0; lIndex < CardTypeResult[cbCardType].cbCardTypeCount; ++lIndex) {
					int wMeChairID1 = (m_wBankerUser + 1) % Constants.DDZ_PLAYER;

					if (TestOutAllCard(wMeChairID1, CardTypeResult[cbCardType].cbCardData[lIndex],
							CardTypeResult[cbCardType].cbEachHandCardCount[lIndex], true)) {
						// 计算单牌
						int cbTmpSingleCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
								CardTypeResult[cbCardType].cbCardData[lIndex],
								CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);

						// 结果判断
						if (cbTmpSingleCount >= Constants.MAX_COUNT)
							continue;

						// 炸弹优先级排后
						int cbBombCardType = GetCardType(CardTypeResult[cbCardType].cbCardData[lIndex],
								CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);
						if (cbBombCardType == Constants.CT_BOMB_CARD)
							cbTmpSingleCount += 4;
						else if (cbBombCardType == Constants.CT_MISSILE_CARD)
							cbTmpSingleCount += 5;
						else if (15 == GetCardLogicValue(CardTypeResult[cbCardType].cbCardData[lIndex][0]))
							cbTmpSingleCount += 2;
						else if (15 < GetCardLogicValue(CardTypeResult[cbCardType].cbCardData[lIndex][0]))
							cbTmpSingleCount += 3;

						//// 改变权值
						// if (cbBombCardType != CT_ERROR) cbTmpSingleCount +=
						//// cbBombCardType ;

						if (cbTmpSingleCount <= cbSingleCardCount) {
							// 设置变量
							OutCardResult.cbCardCount = CardTypeResult[cbCardType].cbEachHandCardCount[lIndex];
							Constants.CopyMemory(OutCardResult.cbResultCard,
									CardTypeResult[cbCardType].cbCardData[lIndex],
									CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);
							cbSingleCardCount = cbTmpSingleCount;

							bFindBestCard = true;
						}
					}
				}
			}
		// 直接返回
		if (bFindBestCard)
			return;

		// 对王和两单
		if (cbHandCardCount == 4 && GetCardLogicValue(cbHandCardData[1]) == 16 && m_cbUserCardCount[m_wBankerUser] == 1
				&& GetCardLogicValue(cbHandCardData[2]) < GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0])) {
			OutCardResult.cbCardCount = 1;
			OutCardResult.cbResultCard[0] = cbHandCardData[2];
			return;
		}

		// 四带牌型判断
		if (AnalyseFourCardType(cbHandCardData, cbHandCardCount, m_cbAllCardData[m_wBankerUser],
				m_cbUserCardCount[m_wBankerUser], OutCardResult)) {
			return;
		}

		// 如果有顺牌和单只或一对，而且单只或对比地主的小，则先出顺
		{
			if (cbLineCardCount + 1 == cbHandCardCount
					&& Constants.CT_SINGLE == GetCardType(cbLineCard, cbLineCardCount)) {
				OutCardResult.cbCardCount = cbLineCardCount;
				Constants.CopyMemory(OutCardResult.cbResultCard, cbLineCard, cbLineCardCount);
			} else if (cbThreeLineCardCount + 1 == cbHandCardCount
					&& Constants.CT_THREE_LINE == GetCardType(cbThreeLineCard, cbThreeLineCardCount)) {
				OutCardResult.cbCardCount = cbThreeLineCardCount;
				Constants.CopyMemory(OutCardResult.cbResultCard, cbThreeLineCard, cbThreeLineCardCount);
			} else if (cbDoubleLineCount + 1 == cbHandCardCount
					&& Constants.CT_DOUBLE_LINE == GetCardType(cbDoubleLineCard, cbDoubleLineCount)) {
				OutCardResult.cbCardCount = cbDoubleLineCount;
				Constants.CopyMemory(OutCardResult.cbResultCard, cbDoubleLineCard, cbDoubleLineCount);
			}
			// 双王炸弹和一手
			else if (cbHandCardCount > 2 && cbHandCardData[0] == 0x4f && cbHandCardData[1] == 0x4e
					&& Constants.CT_ERROR != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)
					&& Constants.CT_FOUR_LINE_TAKE_ONE != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)
					&& Constants.CT_FOUR_LINE_TAKE_TWO != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)) {
				OutCardResult.cbCardCount = 2;
				OutCardResult.cbResultCard[0] = 0x4f;
				OutCardResult.cbResultCard[1] = 0x4e;
			}

			if (OutCardResult.cbCardCount > 0) {
				return;
			}
		}
		// 对王加一只
		if (cbHandCardCount == 3 && GetCardColor(cbHandCardData[0]) == 0x40
				&& GetCardColor(cbHandCardData[1]) == 0x40) {
			OutCardResult.cbCardCount = 2;
			OutCardResult.cbResultCard[0] = 0x4f;
			OutCardResult.cbResultCard[1] = 0x4e;
			return;
		}
		// 对王
		else if (cbHandCardCount == 2 && GetCardColor(cbHandCardData[0]) == 0x40
				&& GetCardColor(cbHandCardData[1]) == 0x40) {
			OutCardResult.cbCardCount = 2;
			OutCardResult.cbResultCard[0] = 0x4f;
			OutCardResult.cbResultCard[1] = 0x4e;
			return;
		}
		// 只剩一手牌
		else if (Constants.CT_ERROR != GetCardType(cbHandCardData, cbHandCardCount)
				&& Constants.CT_FOUR_LINE_TAKE_ONE != GetCardType(cbHandCardData, cbHandCardCount)
				&& Constants.CT_FOUR_LINE_TAKE_TWO != GetCardType(cbHandCardData, cbHandCardCount)) {
			OutCardResult.cbCardCount = cbHandCardCount;
			Constants.CopyMemory(OutCardResult.cbResultCard, cbHandCardData, cbHandCardCount);
			return;
		}

		// 只剩一张和一手
		if (cbHandCardCount >= 2) {
			// 地主扑克
			tagOutCardTypeResult_Server BankerCanOutCardType1[] = new tagOutCardTypeResult_Server[13];
			tagOutCardTypeResult_Server.init(BankerCanOutCardType1);
			// Constants.ZeroMemory(BankerCanOutCardType1,sizeof(BankerCanOutCardType1));
			tagOutCardTypeResult_Server BankerCanOutCardType2[] = new tagOutCardTypeResult_Server[13];
			tagOutCardTypeResult_Server.init(BankerCanOutCardType2);
			// Constants.ZeroMemory(BankerCanOutCardType2,sizeof(BankerCanOutCardType2));

			int cbFirstHandCardType = GetCardType(cbHandCardData, cbHandCardCount - 1);
			int cbSecondHandCardType = GetCardType(cbHandCardData, 1, cbHandCardCount - 1);

			// 是否有炸
			int cbAllBombCardData[] = new int[Constants.MAX_COUNT], cbAllBombCount = 0;
			cbAllBombCount = GetAllBomCard(cbHandCardData, cbHandCardCount, cbAllBombCardData, cbAllBombCount);

			// 没有炸弹
			if (cbAllBombCount <= 0 && cbFirstHandCardType != Constants.CT_THREE_LINE_TAKE_ONE
					&& cbFirstHandCardType != Constants.CT_THREE_LINE_TAKE_TWO) {
				// 地主可以出的牌
				if (cbFirstHandCardType != Constants.CT_ERROR)
					AnalyseOutCardType(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser], cbHandCardData,
							cbHandCardCount - 1, BankerCanOutCardType1);
				if (cbSecondHandCardType != Constants.CT_ERROR)
					AnalyseOutCardType(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser], cbHandCardData,
							1, cbHandCardCount - 1, BankerCanOutCardType2);

				if (cbSecondHandCardType != Constants.CT_ERROR
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO
						&& BankerCanOutCardType2[cbSecondHandCardType].cbCardTypeCount == 0
						&& BankerCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0) {
					OutCardResult.cbCardCount = cbHandCardCount - 1;
					Constants.CopyMemory(OutCardResult.cbResultCard, cbHandCardData, 1, cbHandCardCount - 1);
					return;
				}

				if (cbFirstHandCardType != Constants.CT_ERROR && cbFirstHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbFirstHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO
						&& BankerCanOutCardType1[cbFirstHandCardType].cbCardTypeCount == 0
						&& BankerCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0) {
					OutCardResult.cbCardCount = cbHandCardCount - 1;
					Constants.CopyMemory(OutCardResult.cbResultCard, cbHandCardData, cbHandCardCount - 1);
					return;
				}

				if (GetCardLogicValue(cbHandCardData[0]) >= GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0])
						&& Constants.CT_ERROR != cbSecondHandCardType
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO
						&& BankerCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0) {
					OutCardResult.cbCardCount = 1;
					OutCardResult.cbResultCard[0] = cbHandCardData[0];
					return;
				}

				if (Constants.CT_ERROR != cbSecondHandCardType
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_ONE
						&& cbSecondHandCardType != Constants.CT_FOUR_LINE_TAKE_TWO
						&& BankerCanOutCardType2[Constants.CT_BOMB_CARD].cbCardTypeCount == 0) {
					OutCardResult.cbCardCount = cbHandCardCount - 1;
					Constants.CopyMemory(OutCardResult.cbResultCard, cbHandCardData, 1, cbHandCardCount - 1);
					return;
				}
			}
			// 还有炸弹
			else {
				// 除去炸后的牌
				int cbRemainCard[] = new int[Constants.MAX_COUNT], cbRemainCount = 0;
				Constants.CopyMemory(cbRemainCard, cbHandCardData, cbHandCardCount);
				cbRemainCount = cbHandCardCount;
				RemoveCard(cbAllBombCardData, cbAllBombCount, cbRemainCard, cbRemainCount);
				cbRemainCount -= cbAllBombCount;
				if (GetCardType(cbRemainCard, cbRemainCount) != Constants.CT_ERROR) {
					OutCardResult.cbCardCount = cbRemainCount;
					Constants.CopyMemory(OutCardResult.cbResultCard, cbRemainCard, cbRemainCount);
					return;
				}
			}
		}

		// 放走队友
		int wFriendID = (m_wBankerUser + 2) % Constants.DDZ_PLAYER;
		int cbFriendCardType = GetCardType(m_cbAllCardData[wFriendID], m_cbUserCardCount[wFriendID]);

		// 单张扑克
		if (Constants.CT_SINGLE == cbFriendCardType) {
			// 合法判断
			// ASSERT(m_cbUserCardCount[wFriendID]==1);
			if (m_cbUserCardCount[wFriendID] == 1 && GetCardLogicValue(
					cbHandCardData[cbHandCardCount - 1]) < GetCardLogicValue(m_cbAllCardData[wFriendID][0])) {
				OutCardResult.cbCardCount = 1;
				OutCardResult.cbResultCard[0] = cbHandCardData[cbHandCardCount - 1];
				return;
			}
		}
		// 一对扑克
		else if (Constants.CT_DOUBLE == cbFriendCardType && cbDoubleLineCount >= 2) {
			if (GetCardLogicValue(cbDoubleLineCard[cbDoubleLineCount - 1]) < GetCardLogicValue(
					m_cbAllCardData[wFriendID][0])) {
				OutCardResult.cbCardCount = 2;
				OutCardResult.cbResultCard[0] = cbDoubleLineCard[cbDoubleLineCount - 2];
				OutCardResult.cbResultCard[1] = cbDoubleLineCard[cbDoubleLineCount - 1];

				return;
			}
		}

		// 对牌接牌判断
		if (1 == m_cbUserCardCount[m_wBankerUser] && cbHandCardCount >= 2 && m_cbUserCardCount[wFriendID] >= 2) {
			tagAnalyseResult_Server MeAnalyseResult = new tagAnalyseResult_Server();

			// 分析扑克
			AnalysebCardData(cbHandCardData, cbHandCardCount, MeAnalyseResult);

			tagAnalyseResult_Server FriendAnalyseResult = new tagAnalyseResult_Server();

			// 分析扑克
			AnalysebCardData(m_cbAllCardData[wFriendID], m_cbUserCardCount[wFriendID], FriendAnalyseResult);

			// 对牌判断
			if ((m_cbUserCardCount[wFriendID] == (FriendAnalyseResult.cbDoubleCount * 2
					+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4)
					|| m_cbUserCardCount[wFriendID] == (FriendAnalyseResult.cbDoubleCount * 2
							+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4 + 1))
					&& MeAnalyseResult.cbDoubleCount > 0 && FriendAnalyseResult.cbDoubleCount > 0) {
				// 最小对子
				int cbMeLeastDoubleCardLogic = GetCardLogicValue(
						MeAnalyseResult.cbDoubleCardData[MeAnalyseResult.cbDoubleCount * 2 - 2]);
				// 最大对子
				int cbFriendLargestDoublecardLogic = GetCardLogicValue(FriendAnalyseResult.cbDoubleCardData[0]);

				// 出对判断
				if (cbMeLeastDoubleCardLogic < 14 && cbMeLeastDoubleCardLogic < cbFriendLargestDoublecardLogic) {
					OutCardResult.cbCardCount = 2;
					OutCardResult.cbResultCard[0] = MeAnalyseResult.cbDoubleCardData[MeAnalyseResult.cbDoubleCount * 2
							- 2];
					OutCardResult.cbResultCard[1] = MeAnalyseResult.cbDoubleCardData[MeAnalyseResult.cbDoubleCount * 2
							- 1];
					return;
				}

			}
		}

		// 下家为地主，而且地主扑克少于5张
		// if(m_cbUserCardCount[m_wBankerUser]<=5)
		{
			// 分析扑克
			tagOutCardTypeResult_Server MeOutCardTypeResult[] = new tagOutCardTypeResult_Server[13];
			tagOutCardTypeResult_Server.init(MeOutCardTypeResult);
			// ZeroMemory(MeOutCardTypeResult,sizeof(MeOutCardTypeResult));
			AnalyseOutCardType(cbHandCardData, cbHandCardCount, MeOutCardTypeResult);

			// 对家扑克
			int wFriendID1 = 0;
			for (int wChairID = 0; wChairID < Constants.DDZ_PLAYER; ++wChairID)
				if (wChairID != m_wBankerUser && wMeChairID != wChairID)
					wFriendID1 = wChairID;

			// 计算单牌
			int cbMinSingleCardCount[] = new int[4];
			cbMinSingleCardCount[0] = Constants.MAX_COUNT;
			cbMinSingleCardCount[1] = Constants.MAX_COUNT;
			cbMinSingleCardCount[2] = Constants.MAX_COUNT;
			cbMinSingleCardCount[3] = Constants.MAX_COUNT;
			int cbIndex[] = { 0, 0, 0, 0 };
			int cbOutcardType[] = { Constants.CT_ERROR, Constants.CT_ERROR, Constants.CT_ERROR, Constants.CT_ERROR };
			int cbMinValue = Constants.MAX_COUNT;
			int cbMinSingleCountInFour = Constants.MAX_COUNT;
			int cbMinCardType = Constants.CT_ERROR;
			int cbMinIndex = 0;

			// 除炸弹外的牌
			for (int cbCardType = Constants.CT_DOUBLE; cbCardType < Constants.CT_BOMB_CARD; ++cbCardType) {
				tagOutCardTypeResult_Server tmpCardResult = MeOutCardTypeResult[cbCardType];

				// 相同牌型，相同长度，单连，对连等相同牌型可能长度不一样
				int cbThisHandCardCount = Constants.MAX_COUNT;

				// 地主扑克
				tagOutCardTypeResult_Server BankerCanOutCard[] = new tagOutCardTypeResult_Server[13];
				tagOutCardTypeResult_Server.init(BankerCanOutCard);
				// ZeroMemory(BankerCanOutCard,sizeof(BankerCanOutCard));

				tagOutCardTypeResult_Server FriendOutCardTypeResult[] = new tagOutCardTypeResult_Server[13];
				tagOutCardTypeResult_Server.init(FriendOutCardTypeResult);
				// ZeroMemory(FriendOutCardTypeResult,sizeof(FriendOutCardTypeResult));

				for (int i = 0; i < tmpCardResult.cbCardTypeCount; ++i) {
					// 拆三条判断
					if (cbCardType == Constants.CT_DOUBLE) {
						tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();

						AnalysebCardData(cbHandCardData, cbHandCardCount, AnalyseResult);
						if (AnalyseResult.cbSignedCount + AnalyseResult.cbThreeCount * 3 == cbHandCardCount) {
							boolean bContinue = false;
							for (int cbThreeIndex = 0; cbThreeIndex < AnalyseResult.cbThreeCount; ++cbThreeIndex)
								if (GetCardValue(tmpCardResult.cbCardData[i][0]) == GetCardValue(
										AnalyseResult.cbThreeCardData[3 * cbThreeIndex])) {
									bContinue = true;
									break;
								}
							if (bContinue)
								continue;
						}
					}

					int cbTmpCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, tmpCardResult.cbCardData[i],
							tmpCardResult.cbEachHandCardCount[i]);

					// 重新分析
					if (tmpCardResult.cbEachHandCardCount[i] != cbThisHandCardCount) {
						cbThisHandCardCount = tmpCardResult.cbEachHandCardCount[i];
						AnalyseOutCardType(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser],
								tmpCardResult.cbCardData[i], tmpCardResult.cbEachHandCardCount[i], BankerCanOutCard);
						AnalyseOutCardType(m_cbAllCardData[wFriendID1], m_cbUserCardCount[wFriendID1],
								tmpCardResult.cbCardData[i], tmpCardResult.cbEachHandCardCount[i],
								FriendOutCardTypeResult);
					}

					int cbMaxValue = 0;
					int Index = 0;

					// 针对顺子，三条的大牌
					int cbCurrentCardType = GetCardType(tmpCardResult.cbCardData[i], cbThisHandCardCount);
					if (cbThisHandCardCount != cbHandCardCount && cbCurrentCardType >= Constants.CT_SINGLE_LINE
							&& cbCurrentCardType <= Constants.CT_THREE_LINE_TAKE_TWO
							&& (GetCardLogicValue(
									tmpCardResult.cbCardData[i][cbThisHandCardCount - 1]) > GetCardLogicValue(
											cbHandCardData[cbHandCardCount - 2])
									|| GetCardLogicValue(tmpCardResult.cbCardData[i][0]) >= 11)) {
						int cbRemainCardData[] = new int[Constants.MAX_COUNT], cbRemainCardCount;
						Constants.CopyMemory(cbRemainCardData, cbHandCardData, cbHandCardCount);
						cbRemainCardCount = cbHandCardCount;

						// 移除扑克
						RemoveCard(tmpCardResult.cbCardData[i], cbThisHandCardCount, cbRemainCardData,
								cbRemainCardCount);
						cbRemainCardCount -= cbThisHandCardCount;

						// 最大扑克
						int cbCurrentLargestLogicCard = GetCardLogicValue(tmpCardResult.cbCardData[i][0]);

						if (GetCardType(cbRemainCardData, cbRemainCardCount) == Constants.CT_ERROR
								&& (cbCurrentCardType >= Constants.CT_THREE_LINE_TAKE_ONE
										&& cbCurrentCardType <= Constants.CT_THREE_LINE_TAKE_TWO
										&& cbCurrentLargestLogicCard >= 11 && cbThisHandCardCount <= 5
										|| cbCurrentCardType == Constants.CT_SINGLE_LINE && cbThisHandCardCount <= 6
												&& cbCurrentLargestLogicCard >= 12
										|| cbCurrentCardType >= Constants.CT_DOUBLE_LINE
												&& cbCurrentCardType <= Constants.CT_THREE_LINE
												&& cbCurrentLargestLogicCard >= 12 && cbThisHandCardCount <= 8)) {
							// 暂时不出
							if (cbCurrentCardType >= Constants.CT_SINGLE_LINE
									&& cbCurrentCardType <= Constants.CT_THREE_LINE
									&& GetCardLogicValue(
											tmpCardResult.cbCardData[i][cbThisHandCardCount - 1]) > GetCardLogicValue(
													cbHandCardData[cbHandCardCount - 3]))
								continue;

							if (cbCurrentCardType >= Constants.CT_THREE_LINE_TAKE_ONE
									&& cbCurrentCardType <= Constants.CT_THREE_LINE_TAKE_TWO
									&& GetCardLogicValue(tmpCardResult.cbCardData[i][0]) > GetCardLogicValue(
											cbHandCardData[cbHandCardCount - 3]))
								continue;
						}
					}

					// 针对大对（不可先出）
					if (cbCardType == Constants.CT_DOUBLE && GetCardLogicValue(tmpCardResult.cbCardData[i][0]) >= 11) {
						int cbAllSingleCardData[] = new int[Constants.MAX_COUNT], cbAllSingleCount = 0;
						cbAllSingleCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0,
								cbAllSingleCardData);
						if (cbAllSingleCount >= 2 && GetCardLogicValue(cbAllSingleCardData[cbAllSingleCount - 2]) < 10)
							continue;
					}

					// 地主可以压牌，而且队友不可以压地主
					if ((BankerCanOutCard[cbCardType].cbCardTypeCount > 0
							&& FriendOutCardTypeResult[cbCardType].cbCardTypeCount == 0)
							|| (BankerCanOutCard[cbCardType].cbCardTypeCount > 0
									&& FriendOutCardTypeResult[cbCardType].cbCardTypeCount > 0
									&& GetCardLogicValue(
											FriendOutCardTypeResult[cbCardType].cbCardData[0][0]) <= GetCardLogicValue(
													BankerCanOutCard[cbCardType].cbCardData[0][0]))) {
						// 地主跑掉
						if (BankerCanOutCard[cbCardType].cbEachHandCardCount[0] > 0
								&& m_cbUserCardCount[m_wBankerUser] <= BankerCanOutCard[cbCardType].cbEachHandCardCount[0]
										+ 1)
							continue;

						// 自己不可以再拿回牌权
						// if(GetCardLogicValue(tmpCardResult.cbCardData[0][0])
						// <
						// GetCardLogicValue(BankerCanOutCard[cbCardType].cbCardData[0][0])
						// &&
						// BankerCanOutCard[cbCardType].cbCardTypeCount > 0)
						// continue ;
					}
					// 是否有大牌
					if (tmpCardResult.cbEachHandCardCount[i] != cbHandCardCount) {
						boolean bHaveLargeCard = false;
						for (int j = 0; j < tmpCardResult.cbEachHandCardCount[i]; ++j)
							if (GetCardLogicValue(tmpCardResult.cbCardData[i][j]) >= 15)
								bHaveLargeCard = true;

						if (cbCardType != Constants.CT_SINGLE_LINE && cbCardType != Constants.CT_DOUBLE_LINE
								&& GetCardLogicValue(tmpCardResult.cbCardData[i][0]) == 14)
							bHaveLargeCard = true;

						if (bHaveLargeCard)
							continue;
					}

					// 地主是否可以走掉，这里都没有考虑炸弹
					if (tmpCardResult.cbEachHandCardCount[i] == m_cbUserCardCount[m_wBankerUser]
							&& cbCardType == GetCardType(m_cbAllCardData[m_wBankerUser],
									m_cbUserCardCount[m_wBankerUser])
							&& GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0]) > GetCardLogicValue(
									tmpCardResult.cbCardData[i][0]))
						continue;

					// 搜索cbMinSingleCardCount[4]的最大值
					for (int j = 0; j < 4; ++j) {
						if (cbMinSingleCardCount[j] >= cbTmpCount) {
							cbMinSingleCardCount[j] = cbTmpCount;
							cbIndex[j] = i;
							cbOutcardType[j] = cbCardType;
							break;
						}
					}

					// 保存最小值
					if (cbMinSingleCountInFour >= cbTmpCount) {
						// 最小牌型
						cbMinCardType = cbCardType;
						// 最小牌型中的最小单牌
						cbMinSingleCountInFour = cbTmpCount;
						// 最小牌型中的最小牌
						cbMinIndex = i;
					}
				}
			}

			if (cbMinSingleCountInFour >= AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0) + 3
					&& m_cbUserCardCount[m_wBankerUser] > 4)
				cbMinSingleCountInFour = Constants.MAX_COUNT;

			if (cbMinSingleCountInFour != Constants.MAX_COUNT) {
				int Index = cbMinIndex;

				// 选择最小牌
				for (int i = 0; i < 4; ++i) {
					if (cbOutcardType[i] == cbMinCardType && cbMinSingleCardCount[i] <= cbMinSingleCountInFour
							&& GetCardLogicValue(
									MeOutCardTypeResult[cbMinCardType].cbCardData[cbIndex[i]][0]) < GetCardLogicValue(
											MeOutCardTypeResult[cbMinCardType].cbCardData[Index][0]))
						Index = cbIndex[i];
				}

				// 对王加一只
				if (cbHandCardCount == 3 && GetCardColor(cbHandCardData[0]) == 0x40
						&& GetCardColor(cbHandCardData[1]) == 0x40) {
					OutCardResult.cbCardCount = 2;
					OutCardResult.cbResultCard[0] = 0x4f;
					OutCardResult.cbResultCard[1] = 0x4e;
					return;
				}
				// 对王
				else if (cbHandCardCount == 2 && GetCardColor(cbHandCardData[0]) == 0x40
						&& GetCardColor(cbHandCardData[1]) == 0x40) {
					OutCardResult.cbCardCount = 2;
					OutCardResult.cbResultCard[0] = 0x4f;
					OutCardResult.cbResultCard[1] = 0x4e;
					return;
				} else {
					// 设置变量
					OutCardResult.cbCardCount = MeOutCardTypeResult[cbMinCardType].cbEachHandCardCount[Index];
					Constants.CopyMemory(OutCardResult.cbResultCard,
							MeOutCardTypeResult[cbMinCardType].cbCardData[Index],
							MeOutCardTypeResult[cbMinCardType].cbEachHandCardCount[Index]);
					return;
				}
			}

			// 如果地主扑克少于5，还没有找到适合的牌则从大出到小
			if (OutCardResult.cbCardCount <= 0 && m_cbUserCardCount[m_wBankerUser] <= 5) {
				// 只有一张牌时不能放地主走
				if (m_cbUserCardCount[m_wBankerUser] == 1
						&& MeOutCardTypeResult[Constants.CT_SINGLE].cbCardTypeCount > 0) {
					// 最小一张
					int Index = Constants.MAX_COUNT;
					for (int i = 0; i < MeOutCardTypeResult[Constants.CT_SINGLE].cbCardTypeCount; ++i) {
						if (GetCardLogicValue(
								MeOutCardTypeResult[Constants.CT_SINGLE].cbCardData[i][0]) >= GetCardLogicValue(
										m_cbAllCardData[m_wBankerUser][0])) {
							Index = i;
						} else
							break;
					}

					if (Constants.MAX_COUNT != Index) {
						OutCardResult.cbCardCount = MeOutCardTypeResult[Constants.CT_SINGLE].cbEachHandCardCount[Index];
						Constants.CopyMemory(OutCardResult.cbResultCard,
								MeOutCardTypeResult[Constants.CT_SINGLE].cbCardData[Index], OutCardResult.cbCardCount);
						return;
					}
				}
			}
		}

		int cbFirstCard = 0;
		// 过滤王和2
		for (int i = 0; i < cbHandCardCount; ++i)
			if (GetCardLogicValue(cbHandCardData[i]) < 15) {
				cbFirstCard = i;
				break;
			}

		if (cbFirstCard < cbHandCardCount - 1)
			AnalyseOutCardType(cbHandCardData, cbFirstCard, cbHandCardCount - cbFirstCard, CardTypeResult);
		else
			AnalyseOutCardType(cbHandCardData, cbHandCardCount, CardTypeResult);

		// 计算单牌
		int cbMinSingleCardCount[] = new int[4];
		cbMinSingleCardCount[0] = Constants.MAX_COUNT;
		cbMinSingleCardCount[1] = Constants.MAX_COUNT;
		cbMinSingleCardCount[2] = Constants.MAX_COUNT;
		cbMinSingleCardCount[3] = Constants.MAX_COUNT;
		int cbIndex[] = { 0, 0, 0, 0 };
		int cbOutcardType[] = { Constants.CT_ERROR, Constants.CT_ERROR, Constants.CT_ERROR, Constants.CT_ERROR };
		int cbMinValue = Constants.MAX_COUNT;
		int cbMinSingleCountInFour = Constants.MAX_COUNT;
		int cbMinCardType = Constants.CT_ERROR;
		int cbMinIndex = 0;

		// 除炸弹外的牌
		for (int cbCardType = Constants.CT_SINGLE; cbCardType < Constants.CT_BOMB_CARD; ++cbCardType) {
			tagOutCardTypeResult_Server tmpCardResult = CardTypeResult[cbCardType];
			for (int i = 0; i < tmpCardResult.cbCardTypeCount; ++i) {
				// 庄家可以走掉
				if (CompareCard(tmpCardResult.cbCardData[i], m_cbAllCardData[m_wBankerUser],
						tmpCardResult.cbEachHandCardCount[i], m_cbUserCardCount[m_wBankerUser]))
					continue;

				// 针对顺子，三条的大牌
				if (tmpCardResult.cbEachHandCardCount[i] != cbHandCardCount && cbCardType >= Constants.CT_SINGLE_LINE
						&& cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO
						&& (GetCardLogicValue(tmpCardResult.cbCardData[i][tmpCardResult.cbEachHandCardCount[i]
								- 1]) > GetCardLogicValue(cbHandCardData[cbHandCardCount - 2])
								|| GetCardLogicValue(tmpCardResult.cbCardData[i][0]) >= 11)) {
					int cbRemainCardData[] = new int[Constants.MAX_COUNT], cbRemainCardCount = 0;
					Constants.CopyMemory(cbRemainCardData, cbHandCardData, cbHandCardCount);
					cbRemainCardCount = cbHandCardCount;

					// 移除扑克
					RemoveCard(tmpCardResult.cbCardData[i], tmpCardResult.cbEachHandCardCount[i], cbRemainCardData,
							cbRemainCardCount);
					cbRemainCardCount -= tmpCardResult.cbEachHandCardCount[i];

					// 最大扑克
					int cbCurrentLargestLogicCard = GetCardLogicValue(tmpCardResult.cbCardData[i][0]);

					if (GetCardType(cbRemainCardData, cbRemainCardCount) == Constants.CT_ERROR
							&& (cbCardType >= Constants.CT_THREE_LINE_TAKE_ONE
									&& cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO && cbCurrentLargestLogicCard >= 11
									&& tmpCardResult.cbEachHandCardCount[i] <= 5
									|| cbCardType == Constants.CT_SINGLE_LINE
											&& tmpCardResult.cbEachHandCardCount[i] <= 6
											&& cbCurrentLargestLogicCard >= 12
									|| cbCardType >= Constants.CT_DOUBLE_LINE && cbCardType <= Constants.CT_THREE_LINE
											&& cbCurrentLargestLogicCard >= 12
											&& tmpCardResult.cbEachHandCardCount[i] <= 8)) {
						// 暂时不出
						if (cbCardType >= Constants.CT_SINGLE_LINE && cbCardType <= Constants.CT_THREE_LINE
								&& GetCardLogicValue(tmpCardResult.cbCardData[i][tmpCardResult.cbEachHandCardCount[i]
										- 1]) > GetCardLogicValue(cbHandCardData[cbHandCardCount - 3]))
							continue;

						if (cbCardType >= Constants.CT_THREE_LINE_TAKE_ONE
								&& cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO
								&& GetCardLogicValue(tmpCardResult.cbCardData[i][0]) > GetCardLogicValue(
										cbHandCardData[cbHandCardCount - 3]))
							continue;
					}
				}

				int cbTmpCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, tmpCardResult.cbCardData[i],
						tmpCardResult.cbEachHandCardCount[i]);

				int cbMaxValue = 0;
				int Index = 0;

				// 搜索cbMinSingleCardCount[4]的最大值
				for (int j = 0; j < 4; ++j) {
					if (cbMinSingleCardCount[j] >= cbTmpCount) {
						cbMinSingleCardCount[j] = cbTmpCount;
						cbIndex[j] = i;
						cbOutcardType[j] = cbCardType;
						break;
					}
				}

				// 保存最小值
				if (cbMinSingleCountInFour >= cbTmpCount) {
					// 最小牌型
					cbMinCardType = cbCardType;
					// 最小牌型中的最小单牌
					cbMinSingleCountInFour = cbTmpCount;
					// 最小牌型中的最小牌
					cbMinIndex = i;
				}
			}
		}

		if (cbMinSingleCountInFour != Constants.MAX_COUNT) {
			int Index = cbMinIndex;

			// 选择最小牌
			for (int i = 0; i < 4; ++i) {
				if (cbOutcardType[i] == cbMinCardType && cbMinSingleCardCount[i] <= cbMinSingleCountInFour
						&& GetCardLogicValue(
								CardTypeResult[cbMinCardType].cbCardData[cbIndex[i]][0]) < GetCardLogicValue(
										CardTypeResult[cbMinCardType].cbCardData[Index][0]))
					Index = cbIndex[i];
			}

			// 对王加一只
			if (cbHandCardCount == 3 && GetCardColor(cbHandCardData[0]) == 0x40
					&& GetCardColor(cbHandCardData[1]) == 0x40) {
				OutCardResult.cbCardCount = 2;
				OutCardResult.cbResultCard[0] = 0x4f;
				OutCardResult.cbResultCard[1] = 0x4e;
				return;
			}
			// 对王
			else if (cbHandCardCount == 2 && GetCardColor(cbHandCardData[0]) == 0x40
					&& GetCardColor(cbHandCardData[1]) == 0x40) {
				OutCardResult.cbCardCount = 2;
				OutCardResult.cbResultCard[0] = 0x4f;
				OutCardResult.cbResultCard[1] = 0x4e;
				return;
			} else {
				// 设置变量
				OutCardResult.cbCardCount = CardTypeResult[cbMinCardType].cbEachHandCardCount[Index];
				Constants.CopyMemory(OutCardResult.cbResultCard, CardTypeResult[cbMinCardType].cbCardData[Index],
						CardTypeResult[cbMinCardType].cbEachHandCardCount[Index]);
				return;
			}
		}
		// 如果只剩炸弹
		else if (CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount > 0) {
			// int Index=0 ;
			// int cbLogicCardValue = GetCardLogicValue(0x4F)+1 ;
			//// 最小炸弹
			// for(int i=0; i<CardTypeResult[CT_BOMB_CARD].cbCardTypeCount; ++i)
			// if(cbLogicCardValue>GetCardLogicValue(CardTypeResult[CT_BOMB_CARD].cbCardData[i][0]))
			// {
			// cbLogicCardValue =
			// GetCardLogicValue(CardTypeResult[CT_BOMB_CARD].cbCardData[i][0])
			// ;
			// Index = i ;
			// }

			// //设置变量
			// OutCardResult.cbCardCount=CardTypeResult[CT_BOMB_CARD].cbEachHandCardCount[Index];
			// CopyMemory(OutCardResult.cbResultCard,CardTypeResult[CT_BOMB_CARD].cbCardData[Index],CardTypeResult[CT_BOMB_CARD].cbEachHandCardCount[Index]*sizeof(int));

			// return ;
		}

		int cbAllSingleCardData[] = new int[Constants.MAX_COUNT], cbAllSingleCardCount = 0;
		cbAllSingleCardCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0, cbAllSingleCardData);

		if (cbAllSingleCardCount > 0) {
			// 如果都没有搜索到就出最小的一张
			OutCardResult.cbCardCount = 1;
			OutCardResult.cbResultCard[0] = cbAllSingleCardData[cbAllSingleCardCount - 1];

			return;
		}

		// 如果都没有搜索到就出最小的一张
		OutCardResult.cbCardCount = 1;
		OutCardResult.cbResultCard[0] = cbHandCardData[cbHandCardCount - 1];
		return;
	}

	// 地主下家（后出牌）
	void UndersideOfBankerOutCard(int cbHandCardData[], int cbHandCardCount, int wOutCardUser, int cbTurnCardData[],
			int cbTurnCardCount, tagOutCardResult_Server OutCardResult) {

		// 零下标没用
		tagOutCardTypeResult_Server CardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
		tagOutCardTypeResult_Server.init(CardTypeResult);

		// 出牌类型
		int cbOutCardType = GetCardType(cbTurnCardData, cbTurnCardCount);

		// 搜索可出牌
		tagOutCardTypeResult_Server BankerOutCardTypeResult[] = new tagOutCardTypeResult_Server[13];
		tagOutCardTypeResult_Server.init(BankerOutCardTypeResult);

		AnalyseOutCardType(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser], BankerOutCardTypeResult);
		AnalyseOutCardType(cbHandCardData, cbHandCardCount, cbTurnCardData, cbTurnCardCount, CardTypeResult);

		// 只剩炸弹
		if (cbHandCardCount == CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[0]
				&& (cbOutCardType < Constants.CT_BOMB_CARD || GetCardLogicValue(
						CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[0][0]) > GetCardLogicValue(
								cbTurnCardData[0]))) {
			OutCardResult.cbCardCount = CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[0];
			Constants.CopyMemory(OutCardResult.cbResultCard, CardTypeResult[Constants.CT_BOMB_CARD].cbCardData,
					OutCardResult.cbCardCount);

			return;
		}
		// 双王炸弹和一手
		else if (cbHandCardCount > 2 && cbHandCardData[0] == 0x4f && cbHandCardData[1] == 0x4e
				&& Constants.CT_ERROR != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)
				&& Constants.CT_FOUR_LINE_TAKE_ONE != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)
				&& Constants.CT_FOUR_LINE_TAKE_TWO != GetCardType(cbHandCardData, 2, cbHandCardCount - 2)) {
			OutCardResult.cbCardCount = 2;
			OutCardResult.cbResultCard[0] = 0x4f;
			OutCardResult.cbResultCard[1] = 0x4e;
			return;
		}

		// 炸弹和一手
		int cbRemainCard[] = new int[Constants.MAX_COUNT];
		int cbRemainCount = 0;
		int cbAllBombCard[] = new int[Constants.MAX_COUNT], cbAllBombCount = 0;
		cbAllBombCount = GetAllBomCard(cbHandCardData, cbHandCardCount, cbAllBombCard, cbAllBombCount);

		// 出炸判断
		if (cbAllBombCount > 0 && wOutCardUser == m_wBankerUser) {
			// 剩余扑克
			Constants.CopyMemory(cbRemainCard, cbHandCardData, cbHandCardCount);
			cbRemainCount = cbHandCardCount;
			RemoveCard(cbAllBombCard, cbAllBombCount, cbRemainCard, cbRemainCount);
			cbRemainCount -= cbAllBombCount;

			if (Constants.CT_ERROR != GetCardType(cbRemainCard, cbRemainCount) || (2 == cbRemainCount
					&& GetCardLogicValue(cbRemainCard[0]) > GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0]))) {

				if ((cbOutCardType < Constants.CT_BOMB_CARD
						|| GetCardLogicValue(cbAllBombCard[0]) > GetCardLogicValue(cbTurnCardData[0]))
						&& (CardTypeResult[cbOutCardType].cbCardTypeCount <= 0
								|| Constants.CT_ERROR != GetCardType(cbRemainCard, cbRemainCount))) {
					// 双王炸弹
					if (GetCardColor(cbAllBombCard[0]) == 0x40) {
						OutCardResult.cbCardCount = 2;
						OutCardResult.cbResultCard[0] = 0x4f;
						OutCardResult.cbResultCard[1] = 0x4e;
						return;
					} else {
						// 分析地主牌
						int cbBankerAllBombCard[] = new int[Constants.MAX_COUNT], cbBankerAllBombCardCount = 0;
						cbBankerAllBombCardCount = GetAllBomCard(m_cbAllCardData[m_wBankerUser],
								m_cbUserCardCount[m_wBankerUser], cbBankerAllBombCard, cbBankerAllBombCardCount);

						if (!CompareCard(cbTurnCardData, cbRemainCard, cbTurnCardCount, cbRemainCount)
								|| cbBankerAllBombCardCount <= 0
								|| GetCardLogicValue(cbAllBombCard[0]) > GetCardLogicValue(cbBankerAllBombCard[0])) {
							OutCardResult.cbCardCount = 4;
							Constants.CopyMemory(OutCardResult.cbResultCard, cbAllBombCard, 4);
							return;
						}
					}
				}
			}
		}

		// 只剩一手出炸
		if (CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount > 0
				&& GetCardType(m_cbAllCardData[(m_wBankerUser + 2) % Constants.DDZ_PLAYER],
						m_cbUserCardCount[(m_wBankerUser + 2) % Constants.DDZ_PLAYER]) != Constants.CT_ERROR
				&& GetCardType(m_cbAllCardData[(m_wBankerUser + 2) % Constants.DDZ_PLAYER],
						m_cbUserCardCount[(m_wBankerUser + 2) % Constants.DDZ_PLAYER]) <= Constants.CT_DOUBLE) {
			// 只剩单牌
			if (GetCardType(m_cbAllCardData[(m_wBankerUser + 2) % Constants.DDZ_PLAYER],
					m_cbUserCardCount[(m_wBankerUser + 2) % Constants.DDZ_PLAYER]) == Constants.CT_SINGLE) {
				int cbIndex = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount - 1;
				int cbCardCount = CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[cbIndex];
				Constants.CopyMemory(OutCardResult.cbResultCard,
						CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[cbIndex], cbCardCount);
				OutCardResult.cbCardCount = cbCardCount;

				return;
			} else if (GetCardType(m_cbAllCardData[(m_wBankerUser + 2) % Constants.DDZ_PLAYER],
					m_cbUserCardCount[(m_wBankerUser + 2) % Constants.DDZ_PLAYER]) == Constants.CT_DOUBLE) {
				int cbAllDoubleCard[] = new int[Constants.MAX_COUNT], cbAllDoubleCount = 0;
				cbAllDoubleCount = GetAllDoubleCard(cbHandCardData, cbHandCardCount, cbAllDoubleCard, cbAllDoubleCount);

				if (cbAllDoubleCount > 0 && GetCardLogicValue(cbAllDoubleCard[cbAllDoubleCount - 1]) <= 10) {
					int cbIndex = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount - 1;
					int cbCardCount = CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[cbIndex];
					Constants.CopyMemory(OutCardResult.cbResultCard,
							CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[cbIndex], cbCardCount);
					OutCardResult.cbCardCount = cbCardCount;

					return;
				}
			}

		}

		// 只有一手牌
		if (GetCardType(cbHandCardData, cbHandCardCount) != Constants.CT_FOUR_LINE_TAKE_ONE
				&& GetCardType(cbHandCardData, cbHandCardCount) != Constants.CT_FOUR_LINE_TAKE_TWO
				&& CompareCard(cbTurnCardData, cbHandCardData, cbTurnCardCount, cbHandCardCount)) {
			OutCardResult.cbCardCount = cbHandCardCount;
			Constants.CopyMemory(OutCardResult.cbResultCard, cbHandCardData, cbHandCardCount);

			return;
		}

		// 对牌接牌判断
		if (1 == m_cbUserCardCount[m_wBankerUser] && cbHandCardCount >= 2 && cbOutCardType == Constants.CT_DOUBLE) {
			tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();
			// ZeroMemory(AnalyseResult,sizeof(AnalyseResult));

			// 分析扑克
			AnalysebCardData(cbHandCardData, cbHandCardCount, AnalyseResult);

			// 对牌判断
			if (cbHandCardCount == (AnalyseResult.cbDoubleCount * 2 + AnalyseResult.cbThreeCount * 3
					+ AnalyseResult.cbFourCount * 4)
					|| cbHandCardCount == (AnalyseResult.cbDoubleCount * 2 + AnalyseResult.cbThreeCount * 3
							+ AnalyseResult.cbFourCount * 4 + 1)) {
				// 出对判断
				for (int nIndex = AnalyseResult.cbDoubleCount - 1; nIndex >= 0; --nIndex) {
					if (GetCardLogicValue(AnalyseResult.cbDoubleCardData[nIndex * 2]) > GetCardLogicValue(
							cbTurnCardData[0])) {
						OutCardResult.cbCardCount = 2;
						OutCardResult.cbResultCard[0] = AnalyseResult.cbDoubleCardData[nIndex * 2];
						OutCardResult.cbResultCard[1] = AnalyseResult.cbDoubleCardData[nIndex * 2 + 1];
						return;
					}
				}

				// 出炸判断
				if (AnalyseResult.cbFourCount > 0) {
					// 最小炸弹
					int cbLestBombIndex = AnalyseResult.cbFourCount - 1;

					OutCardResult.cbCardCount = 4;
					OutCardResult.cbResultCard[0] = AnalyseResult.cbFourCardData[cbLestBombIndex * 4];
					OutCardResult.cbResultCard[1] = AnalyseResult.cbFourCardData[cbLestBombIndex * 4 + 1];
					OutCardResult.cbResultCard[2] = AnalyseResult.cbFourCardData[cbLestBombIndex * 4 + 2];
					OutCardResult.cbResultCard[3] = AnalyseResult.cbFourCardData[cbLestBombIndex * 4 + 3];

					return;
				}

			}

			// 分析对家
			if (wOutCardUser != m_wBankerUser) {
				tagAnalyseResult_Server FriendAnalyseResult = new tagAnalyseResult_Server();
				// ZeroMemory(FriendAnalyseResult,sizeof(FriendAnalyseResult));

				// 分析扑克
				AnalysebCardData(m_cbAllCardData[wOutCardUser], m_cbUserCardCount[wOutCardUser], FriendAnalyseResult);

				// 对牌判断
				if (m_cbUserCardCount[wOutCardUser] == (FriendAnalyseResult.cbDoubleCount * 2
						+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4)
						|| m_cbUserCardCount[wOutCardUser] == (FriendAnalyseResult.cbDoubleCount * 2
								+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4 + 1)) {
					return;
				}

				// 零下标没用
				tagOutCardTypeResult_Server FriendCardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
				tagOutCardTypeResult_Server.init(FriendCardTypeResult);
				// ZeroMemory(FriendCardTypeResult,sizeof(FriendCardTypeResult));

				AnalyseOutCardType(m_cbAllCardData[wOutCardUser], m_cbUserCardCount[wOutCardUser],
						FriendCardTypeResult);

				for (int cbLineCardIdx = 0; cbLineCardIdx < FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbCardTypeCount; ++cbLineCardIdx) {
					// 剩余扑克
					int cbRemainCardData[] = new int[Constants.MAX_COUNT], cbRemainCardCount;

					cbRemainCardCount = m_cbUserCardCount[wOutCardUser];
					Constants.CopyMemory(cbRemainCardData, m_cbAllCardData[wOutCardUser], cbRemainCardCount);
					RemoveCard(FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbCardData[cbLineCardIdx],
							FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbEachHandCardCount[cbLineCardIdx],
							cbRemainCardData, cbRemainCardCount);

					cbRemainCardCount -= FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbEachHandCardCount[cbLineCardIdx];

					// 分析扑克
					AnalysebCardData(cbRemainCardData, cbRemainCardCount, FriendAnalyseResult);

					// 对牌判断
					if (cbRemainCardCount == (FriendAnalyseResult.cbDoubleCount * 2
							+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4)
							|| cbRemainCardCount == (FriendAnalyseResult.cbDoubleCount * 2
									+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4 + 1)) {
						return;
					}
				}

				for (int cbLineCardIdx = 0; cbLineCardIdx < FriendCardTypeResult[Constants.CT_DOUBLE_LINE].cbCardTypeCount; ++cbLineCardIdx) {
					// 剩余扑克
					int cbRemainCardData[] = new int[Constants.MAX_COUNT], cbRemainCardCount;

					cbRemainCardCount = m_cbUserCardCount[wOutCardUser];
					Constants.CopyMemory(cbRemainCardData, m_cbAllCardData[wOutCardUser], cbRemainCardCount);
					RemoveCard(FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbCardData[cbLineCardIdx],
							FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbEachHandCardCount[cbLineCardIdx],
							cbRemainCardData, cbRemainCardCount);

					cbRemainCardCount -= FriendCardTypeResult[Constants.CT_SINGLE_LINE].cbEachHandCardCount[cbLineCardIdx];

					// 分析扑克
					AnalysebCardData(cbRemainCardData, cbRemainCardCount, FriendAnalyseResult);

					// 对牌判断
					if (cbRemainCardCount == (FriendAnalyseResult.cbDoubleCount * 2
							+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4)
							|| cbRemainCardCount == (FriendAnalyseResult.cbDoubleCount * 2
									+ FriendAnalyseResult.cbThreeCount * 3 + FriendAnalyseResult.cbFourCount * 4 + 1)) {
						return;
					}
				}

			}
		}

		// 对家可否出完
		if (m_wBankerUser != wOutCardUser && !CompareCard(cbTurnCardData, m_cbAllCardData[m_wBankerUser],
				cbTurnCardCount, m_cbUserCardCount[m_wBankerUser])) {
			// 庄家扑克
			boolean bBankerCanOut = false;
			tagOutCardTypeResult_Server BankerOutCardResult[] = new tagOutCardTypeResult_Server[12 + 1];
			tagOutCardTypeResult_Server.init(BankerOutCardResult);
			// ZeroMemory(BankerOutCardResult,sizeof(BankerOutCardResult));

			// 分析扑克
			AnalyseOutCardType(m_cbAllCardData[m_wBankerUser], m_cbUserCardCount[m_wBankerUser], cbTurnCardData,
					cbTurnCardCount, BankerOutCardResult);
			for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType)
				if (BankerOutCardResult[cbCardType].cbCardTypeCount > 0)
					bBankerCanOut = true;

			if (!bBankerCanOut) {
				// 对家ID
				int wFriendChairID = (m_wBankerUser + 2) % Constants.DDZ_PLAYER;

				// 分析扑克
				tagOutCardTypeResult_Server FriendCardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
				tagOutCardTypeResult_Server.init(FriendCardTypeResult);
				// ZeroMemory(FriendCardTypeResult,sizeof(FriendCardTypeResult));
				AnalyseOutCardType(m_cbAllCardData[wFriendChairID], m_cbUserCardCount[wFriendChairID],
						FriendCardTypeResult);

				for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType)
					if (FriendCardTypeResult[cbCardType].cbCardTypeCount > 0) {
						for (int lIndex = 0; lIndex < FriendCardTypeResult[cbCardType].cbCardTypeCount; ++lIndex) {

							if (TestOutAllCard(wFriendChairID, FriendCardTypeResult[cbCardType].cbCardData[lIndex],
									FriendCardTypeResult[cbCardType].cbEachHandCardCount[lIndex], true)) {
								// 不压对家
								return;
							}
						}
					}
			}
		}

		// 放走对家
		if (GetCardType(m_cbAllCardData[(m_wBankerUser + 2) % Constants.DDZ_PLAYER],
				m_cbUserCardCount[(m_wBankerUser + 2) % Constants.DDZ_PLAYER]) == GetCardType(cbTurnCardData,
						cbTurnCardCount)
				&& CompareCard(cbTurnCardData, m_cbAllCardData[(m_wBankerUser + 2) % Constants.DDZ_PLAYER],
						cbTurnCardCount, m_cbUserCardCount[(m_wBankerUser + 2) % Constants.DDZ_PLAYER]))
			return;

		if (CompareCard(cbTurnCardData, m_cbAllCardData[(m_wBankerUser + 2) % Constants.DDZ_PLAYER], cbTurnCardCount,
				m_cbUserCardCount[(m_wBankerUser + 2) % Constants.DDZ_PLAYER]))
			return;

		// 判断可否出完
		int cbSingleCardCount = Constants.MAX_COUNT + Constants.CT_MISSILE_CARD;
		boolean bFindBestCard = false;
		for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType)
			if (CardTypeResult[cbCardType].cbCardTypeCount > 0) {
				for (int lIndex = 0; lIndex < CardTypeResult[cbCardType].cbCardTypeCount; ++lIndex) {
					int wMeChairID = (m_wBankerUser + 1) % Constants.DDZ_PLAYER;

					if (TestOutAllCard(wMeChairID, CardTypeResult[cbCardType].cbCardData[lIndex],
							CardTypeResult[cbCardType].cbEachHandCardCount[lIndex], false)) {
						// 计算单牌
						int cbTmpSingleCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
								CardTypeResult[cbCardType].cbCardData[lIndex],
								CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);

						// 结果判断
						if (cbTmpSingleCount >= Constants.MAX_COUNT)
							continue;

						// 炸弹优先级排后
						int cbBombCardType = GetCardType(CardTypeResult[cbCardType].cbCardData[lIndex],
								CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);
						if (cbBombCardType == Constants.CT_BOMB_CARD)
							cbTmpSingleCount += 4;
						else if (cbBombCardType == Constants.CT_MISSILE_CARD)
							cbTmpSingleCount += 5;

						//// 改变权值
						// if (cbBombCardType != CT_ERROR) cbTmpSingleCount +=
						//// cbBombCardType ;

						// 不出炸弹
						// int cbWantOutCardType =
						// GetCardType(CardTypeResult[cbCardType].cbCardData[lIndex],
						// CardTypeResult[cbCardType].cbEachHandCardCount[lIndex])
						// ;
						// if (CardTypeResult[cbOutCardType].cbCardTypeCount > 0
						// &&
						// cbOutCardType < CT_BOMB_CARD && cbWantOutCardType >=
						// CT_BOMB_CARD)
						// continue ;

						if (cbTmpSingleCount <= cbSingleCardCount) {
							// 设置变量
							OutCardResult.cbCardCount = CardTypeResult[cbCardType].cbEachHandCardCount[lIndex];
							Constants.CopyMemory(OutCardResult.cbResultCard,
									CardTypeResult[cbCardType].cbCardData[lIndex],
									CardTypeResult[cbCardType].cbEachHandCardCount[lIndex]);
							cbSingleCardCount = cbTmpSingleCount;
							bFindBestCard = true;
						}
					}
				}
			}
		// 直接返回
		if (bFindBestCard)
			return;

		// 取出四个最小单牌
		int cbMinSingleCardCount[] = new int[4];
		cbMinSingleCardCount[0] = Constants.MAX_COUNT;
		cbMinSingleCardCount[1] = Constants.MAX_COUNT;
		cbMinSingleCardCount[2] = Constants.MAX_COUNT;
		cbMinSingleCardCount[3] = Constants.MAX_COUNT;
		int cbIndex[] = { 0, 0, 0, 0 };
		int cbMinSingleCountInFour = Constants.MAX_COUNT;

		// 可出扑克（这里已经过滤掉炸弹了）
		tagOutCardTypeResult_Server CanOutCard = CardTypeResult[cbOutCardType];

		for (int i = 0; i < CanOutCard.cbCardTypeCount; ++i) {
			// 最小单牌
			int cbTmpCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, CanOutCard.cbCardData[i],
					CanOutCard.cbEachHandCardCount[i]);
			int cbMaxValue = 0;
			int Index = 0;

			// 搜索cbMinSingleCardCount[4]的最大值
			for (int j = 0; j < 4; ++j) {
				if (cbMinSingleCardCount[j] >= cbTmpCount) {
					cbMinSingleCardCount[j] = cbTmpCount;
					cbIndex[j] = i;
					break;
				}
			}

		}

		for (int i = 0; i < 4; ++i)
			if (cbMinSingleCountInFour > cbMinSingleCardCount[i])
				cbMinSingleCountInFour = cbMinSingleCardCount[i];

		// 原始单牌数
		int cbOriginSingleCardCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount, null, 0);

		// 朋友出牌
		boolean bFriendOut = m_wBankerUser != wOutCardUser;
		if (bFriendOut) {
			// 不拦截朋友最后一手牌
			if (GetCardType(m_cbAllCardData[(2 + m_wBankerUser) % Constants.DDZ_PLAYER],
					m_cbUserCardCount[(2 + m_wBankerUser) % Constants.DDZ_PLAYER]) != Constants.CT_ERROR)
				return;

			// 在上面的TestOutAllCard中已对可出炸弹情况分析过
			if (CanOutCard.cbCardTypeCount > 0 && CanOutCard.cbCardType < Constants.CT_BOMB_CARD
					&& cbMinSingleCountInFour < Constants.MAX_COUNT) {
				int cbMinLogicCardValue = GetCardLogicValue(0x4F) + 1;
				boolean bFindCard = false;
				int cbCanOutIndex = 0;
				for (int i = 0; i < 4; ++i) {
					int Index = cbIndex[i];

					// 三带，和连牌不接对家牌
					if (CanOutCard.cbCardType >= Constants.CT_THREE
							&& CanOutCard.cbCardType <= Constants.CT_MISSILE_CARD
							&& GetCardLogicValue(CanOutCard.cbCardData[Index][0]) >= 7
							&& CanOutCard.cbEachHandCardCount[Index] <= 5)
						continue;

					// 小于J的牌，或者小于K而且是散牌
					if ((cbMinSingleCardCount[i] < cbOriginSingleCardCount + 3
							&& (cbMinSingleCardCount[i] <= cbMinSingleCountInFour
									|| cbMinSingleCardCount[i] <= cbMinSingleCountInFour + 1
											&& CanOutCard.cbCardType >= Constants.CT_THREE_LINE_TAKE_ONE
											&& CanOutCard.cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO)
							&& (GetCardLogicValue(CanOutCard.cbCardData[Index][0]) <= 11
									|| (cbMinSingleCardCount[i] < cbOriginSingleCardCount)
											&& GetCardLogicValue(CanOutCard.cbCardData[Index][0]) <= 13))
							&& cbMinLogicCardValue > GetCardLogicValue(CanOutCard.cbCardData[Index][0])
							&& cbHandCardCount > 5) {
						// 搜索有没有大牌（针对飞机带翅膀后面的带牌）
						boolean bNoLargeCard = true;
						for (int k = 3; k < CanOutCard.cbEachHandCardCount[Index]; ++k) {
							// 有大牌而且不能一次出完
							if (GetCardLogicValue(CanOutCard.cbCardData[Index][k]) >= 15
									&& CanOutCard.cbEachHandCardCount[Index] != cbHandCardCount)
								bNoLargeCard = false;
						}
						if (bNoLargeCard) {
							bFindCard = true;
							cbCanOutIndex = Index;
							cbMinLogicCardValue = GetCardLogicValue(CanOutCard.cbCardData[Index][0]);
						}
					} else if (cbHandCardCount < 5 && cbMinSingleCardCount[i] < cbOriginSingleCardCount + 4
							&& cbMinSingleCardCount[i] <= cbMinSingleCountInFour
							&& cbMinLogicCardValue > GetCardLogicValue(CanOutCard.cbCardData[Index][0])) {
						// 能出王打自家的2
						if (GetCardLogicValue(CanOutCard.cbCardData[Index][0]) >= 16
								&& GetCardLogicValue(cbTurnCardData[0]) >= 15)
							continue;

						bFindCard = true;
						cbCanOutIndex = Index;
						cbMinLogicCardValue = GetCardLogicValue(CanOutCard.cbCardData[Index][0]);
					}
				}

				if (bFindCard) {

					// 设置变量
					OutCardResult.cbCardCount = CanOutCard.cbEachHandCardCount[cbCanOutIndex];
					Constants.CopyMemory(OutCardResult.cbResultCard, CanOutCard.cbCardData[cbCanOutIndex],
							CanOutCard.cbEachHandCardCount[cbCanOutIndex]);

					return;
				}
				// 手上少于五张牌
				else if (cbHandCardCount <= 5) {
					int cbMinLogicCard = GetCardLogicValue(0x4f) + 1;
					int cbCanOutIndex1 = 0;
					for (int i = 0; i < 4; ++i)
						if (cbMinSingleCardCount[i] < Constants.MAX_COUNT
								&& cbMinSingleCardCount[i] <= cbMinSingleCountInFour
								&& cbMinLogicCard > GetCardLogicValue(CanOutCard.cbCardData[cbIndex[i]][0])
								&& GetCardLogicValue(CanOutCard.cbCardData[cbIndex[i]][0]) <= 14) {
							cbMinLogicCard = GetCardLogicValue(CanOutCard.cbCardData[cbIndex[i]][0]);
							cbCanOutIndex1 = cbIndex[i];
						}

					if (cbMinLogicCard != (GetCardLogicValue(0x4f) + 1)) {
						// 设置变量
						OutCardResult.cbCardCount = CanOutCard.cbEachHandCardCount[cbCanOutIndex1];
						Constants.CopyMemory(OutCardResult.cbResultCard, CanOutCard.cbCardData[cbCanOutIndex1],
								CanOutCard.cbEachHandCardCount[cbCanOutIndex1]);

						return;
					}
				}

				return;
			} else {
				return;
			}

		}
		// 地主出牌
		else {
			if (CanOutCard.cbCardTypeCount > 0 && cbMinSingleCountInFour < Constants.MAX_COUNT) {
				int cbMinLogicCardValue = GetCardLogicValue(0x4F) + 1;
				boolean bFindCard = false;
				int cbCanOutIndex = 0;
				for (int i = 0; i < 4; ++i) {
					int Index = cbIndex[i];

					if ((cbMinSingleCardCount[i] < cbOriginSingleCardCount + 4)
							&& (cbMinSingleCardCount[i] <= cbMinSingleCountInFour
									|| cbMinSingleCardCount[i] <= cbMinSingleCountInFour + 1
											&& CanOutCard.cbCardType >= Constants.CT_THREE_LINE_TAKE_ONE
											&& CanOutCard.cbCardType <= Constants.CT_THREE_LINE_TAKE_TWO)
							&& cbMinLogicCardValue > GetCardLogicValue(CanOutCard.cbCardData[Index][0])) {
						// 针对大牌
						boolean bNoLargeCard = true;

						// 当地主手上牌数大于4，而且地主出的是小于K的牌而且不是地主手上的最大牌时，不能出2去打
						if (m_cbUserCardCount[m_wBankerUser] >= 4 && cbHandCardCount >= 5
								&& CanOutCard.cbEachHandCardCount[Index] >= 2
								&& GetCardLogicValue(CanOutCard.cbCardData[Index][0]) >= 15
								&& GetCardLogicValue(cbTurnCardData[0]) < 13
								&& GetCardLogicValue(cbTurnCardData[0]) < GetCardLogicValue(
										m_cbAllCardData[m_wBankerUser][0])
								&& CanOutCard.cbEachHandCardCount[Index] != cbHandCardCount)
							bNoLargeCard = false;

						// 搜索有没有大牌（针对飞机带翅膀后面的带牌）
						for (int k = 3; k < CanOutCard.cbEachHandCardCount[Index]; ++k) {
							if (GetCardLogicValue(CanOutCard.cbCardData[Index][k]) >= 15
									&& CanOutCard.cbEachHandCardCount[Index] != cbHandCardCount)
								bNoLargeCard = false;
						}
						if (bNoLargeCard) {
							bFindCard = true;
							cbCanOutIndex = Index;
							cbMinLogicCardValue = GetCardLogicValue(CanOutCard.cbCardData[Index][0]);
						}
					}
				}

				if (bFindCard) {
					// 地主的最大牌
					int cbLargestLogicCard = GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0]);
					boolean bCanOut = true;

					// 王只压2
					if (GetCardLogicValue(cbTurnCardData[0]) < cbLargestLogicCard) {
						if (GetCardColor(CanOutCard.cbCardData[cbCanOutIndex][0]) == 0x40
								&& GetCardLogicValue(cbTurnCardData[0]) <= 14 && cbHandCardCount > 5) {
							bCanOut = false;
						}
					}

					// 双王判断
					if (GetCardLogicValue(CanOutCard.cbCardData[cbCanOutIndex][0]) >= 16 && cbHandCardCount >= 2
							&& cbHandCardData[0] == 0x4F && cbHandCardData[1] == 0x4E) {
						boolean bOutMissileCard = false;
						// 一手牌和一个炸弹
						int cbRemainCardData[] = new int[20], cbRemainCardCount = cbHandCardCount;
						Constants.CopyMemory(cbRemainCardData, cbHandCardData, cbHandCardCount);
						RemoveCard(cbRemainCardData, 2, cbRemainCardData, cbRemainCardCount);
						cbRemainCardCount -= 2;
						if (Constants.CT_ERROR != GetCardType(cbRemainCardData, cbRemainCardCount))
							bOutMissileCard = true;

						// 只剩少量牌
						int cbRemainLargestCard = GetCardLogicValue(cbRemainCardData[0]);
						if (cbRemainCardCount < 5 && cbRemainCardCount > 0
								&& GetCardLogicValue(cbRemainCardData[0]) >= 14)
							bOutMissileCard = true;

						// 炸后单牌数
						int cbSingleCardCount1 = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
								CanOutCard.cbCardData[cbCanOutIndex], CanOutCard.cbEachHandCardCount[cbCanOutIndex]);
						if (cbSingleCardCount1 <= 1 && GetCardLogicValue(cbRemainCardData[0]) >= 11)
							bOutMissileCard = true;

						// 还有小牌
						if (GetCardLogicValue(cbRemainCardData[0]) <= 10
								&& Constants.CT_ERROR == GetCardType(cbRemainCardData, cbRemainCardCount)
								&& GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0]) > 10)
							bOutMissileCard = false;

						// 火箭扑克
						if (bOutMissileCard) {
							// 优先其他炸弹
							int cbIndex1 = CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount - 1;

							OutCardResult.cbCardCount = CardTypeResult[Constants.CT_BOMB_CARD].cbEachHandCardCount[cbIndex1];
							Constants.CopyMemory(OutCardResult.cbResultCard,
									CardTypeResult[Constants.CT_BOMB_CARD].cbCardData[cbIndex1],
									OutCardResult.cbCardCount);
							return;
						}
					}
					if (bCanOut) {
						// 设置变量
						OutCardResult.cbCardCount = CanOutCard.cbEachHandCardCount[cbCanOutIndex];
						Constants.CopyMemory(OutCardResult.cbResultCard, CanOutCard.cbCardData[cbCanOutIndex],
								CanOutCard.cbEachHandCardCount[cbCanOutIndex]);

						return;
					}
				}

				if (cbOutCardType == Constants.CT_SINGLE) {
					// 地主的最大牌
					int cbLargestLogicCard = GetCardLogicValue(m_cbAllCardData[m_wBankerUser][0]);

					if (GetCardLogicValue(cbTurnCardData[0]) == 14
							|| GetCardLogicValue(cbTurnCardData[0]) >= cbLargestLogicCard
							|| (GetCardLogicValue(cbTurnCardData[0]) < cbLargestLogicCard - 1)
							|| m_cbUserCardCount[m_wBankerUser] <= 5) {
						// 取一张大于等于2而且要比地主出的牌大的牌，
						int cbIndex1 = Constants.MAX_COUNT;
						for (int i = 0; i < cbHandCardCount; ++i)
							if (GetCardLogicValue(cbHandCardData[i]) > GetCardLogicValue(cbTurnCardData[0])
									&& GetCardLogicValue(cbHandCardData[i]) >= 15) {
								cbIndex1 = i;
							}
						if (cbIndex1 != Constants.MAX_COUNT) {
							// 设置变量
							OutCardResult.cbCardCount = 1;
							OutCardResult.cbResultCard[0] = cbHandCardData[cbIndex1];

							return;
						}
					}
				}

				// 当朋友不能拦截地主时
				int wMeChairID = (m_wBankerUser + 1) % Constants.DDZ_PLAYER;
				int wFriendID = (wMeChairID + 1) % Constants.DDZ_PLAYER;

				tagOutCardTypeResult_Server FriendCardTypeResult[] = new tagOutCardTypeResult_Server[13];
				tagOutCardTypeResult_Server.init(FriendCardTypeResult);
				// ;ZeroMemory(FriendCardTypeResult,sizeof(FriendCardTypeResult));
				AnalyseOutCardType(m_cbAllCardData[wFriendID], m_cbUserCardCount[wFriendID], cbTurnCardData,
						cbTurnCardCount, FriendCardTypeResult);

				// 当朋友不能拦截地主时
				if (m_cbUserCardCount[m_wBankerUser] <= 4 && FriendCardTypeResult[cbOutCardType].cbCardTypeCount == 0
						&& CardTypeResult[cbOutCardType].cbCardTypeCount > 0) {
					int cbMinSingleCount = Constants.MAX_COUNT;
					int Index = 0;
					for (int i = 0; i < CardTypeResult[cbOutCardType].cbCardTypeCount; ++i) {
						int cbTmpCount = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
								CardTypeResult[cbOutCardType].cbCardData[i],
								CardTypeResult[cbOutCardType].cbEachHandCardCount[i]);
						if (cbMinSingleCount >= cbTmpCount) {
							cbMinSingleCount = cbTmpCount;
							Index = i;
						}
					}
					// 设置变量
					OutCardResult.cbCardCount = CardTypeResult[cbOutCardType].cbEachHandCardCount[Index];
					Constants.CopyMemory(OutCardResult.cbResultCard, CardTypeResult[cbOutCardType].cbCardData[Index],
							OutCardResult.cbCardCount);

					return;
				}
			}

			// 还要考虑炸弹
			if (CardTypeResult[Constants.CT_BOMB_CARD].cbCardTypeCount > 0 || (Constants.NORMAL_COUNT == cbHandCardCount
					&& Constants.NORMAL_COUNT == m_cbUserCardCount[(m_wBankerUser + 2) % Constants.DDZ_PLAYER])) {
				tagOutCardTypeResult_Server BomCard = CardTypeResult[Constants.CT_BOMB_CARD];
				int cbMinLogicValue = GetCardLogicValue(BomCard.cbCardData[0][0]);
				int Index = 0;
				for (int i = 0; i < BomCard.cbCardTypeCount; ++i) {
					if (cbMinLogicValue > GetCardLogicValue(BomCard.cbCardData[i][0])) {
						cbMinLogicValue = GetCardLogicValue(BomCard.cbCardData[i][0]);
						Index = i;
					}
				}

				boolean bOutBomb = false;

				// 春天判断
				if (Constants.NORMAL_COUNT == cbHandCardCount
						&& Constants.NORMAL_COUNT == m_cbUserCardCount[(m_wBankerUser + 2) % Constants.DDZ_PLAYER]
						&& Constants.CT_ERROR != GetCardType(m_cbAllCardData[m_wBankerUser],
								m_cbUserCardCount[m_wBankerUser]))
					bOutBomb = true;

				// 一手牌和一个炸弹
				int cbRemainCardData[] = new int[20], cbRemainCardCount = cbHandCardCount;
				Constants.CopyMemory(cbRemainCardData, cbHandCardData, cbHandCardCount);
				RemoveCard(BomCard.cbCardData[Index], BomCard.cbEachHandCardCount[Index], cbRemainCardData,
						cbRemainCardCount);
				cbRemainCardCount -= BomCard.cbEachHandCardCount[Index];
				if (Constants.CT_ERROR != GetCardType(cbRemainCardData, cbRemainCardCount))
					bOutBomb = true;

				// 炸后单牌数
				int cbSingleCardCount1 = AnalyseSinleCardCount(cbHandCardData, cbHandCardCount,
						BomCard.cbCardData[Index], BomCard.cbEachHandCardCount[Index]);
				if (cbSingleCardCount1 == 0 && GetCardLogicValue(cbRemainCardData[0]) > GetCardLogicValue(
						m_cbAllCardData[m_wBankerUser][0]))
					bOutBomb = true;

				// 只剩一手
				int cbRemainCardType = GetCardType(m_cbAllCardData[wOutCardUser], m_cbUserCardCount[wOutCardUser]);
				if (cbRemainCardType > Constants.CT_ERROR && cbRemainCardType < Constants.CT_FOUR_LINE_TAKE_ONE
						&& GetCardLogicValue(m_cbAllCardData[wOutCardUser][0]) < 15 && cbSingleCardCount1 < 2
						&& (GetCardLogicValue(cbRemainCardData[0]) >= GetCardLogicValue(
								m_cbAllCardData[m_wBankerUser][0])))
					bOutBomb = true;

				// 只剩少量牌
				int cbRemainLargestCard = GetCardLogicValue(cbRemainCardData[0]);
				if (cbRemainCardCount < 5 && cbRemainCardCount > 0
						&& (cbRemainLargestCard != GetCardLogicValue(BomCard.cbCardData[Index][0]))
						&& cbRemainLargestCard > GetCardLogicValue(m_cbAllCardData[wOutCardUser][0])
						&& cbRemainLargestCard > 14)
					bOutBomb = true;

				// 分析扑克
				tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();
				AnalysebCardData(cbRemainCardData, cbRemainCardCount, AnalyseResult);

				if (m_cbUserCardCount[m_wBankerUser] == 1 && (AnalyseResult.cbDoubleCount * 2
						+ AnalyseResult.cbThreeCount * 3 + AnalyseResult.cbFourCount * 4 + 1 >= cbRemainCardCount))
					bOutBomb = true;

				// 设置变量
				if (bOutBomb) {
					OutCardResult.cbCardCount = BomCard.cbEachHandCardCount[Index];
					Constants.CopyMemory(OutCardResult.cbResultCard, BomCard.cbCardData[Index],
							BomCard.cbEachHandCardCount[Index]);
				}

				return;
			}

			return;
		}
	}

	// 叫分判断
	int LandScore(int wMeChairID, int cbCurrentLandScore) {

		// 大牌数目
		int cbLargeCardCount = 0;
		int Index = 0;
		while (GetCardLogicValue(m_cbLandScoreCardData[Index++]) >= 15)
			++cbLargeCardCount;

		// 单牌个数
		int cbSingleCardCount = AnalyseSinleCardCount(m_cbLandScoreCardData, Constants.sizeof(m_cbLandScoreCardData),
				null, 0);

		// 叫两分
		if (cbLargeCardCount >= 3 && cbSingleCardCount <= 4)
			return 3;

		// 放弃叫分
		if (cbLargeCardCount <= 2 || cbCurrentLandScore >= 1)
			return 255;

		// 其他单牌
		int cbMinSingleCardCount = Constants.MAX_COUNT;
		for (int wChairID = 0, i = 0; wChairID < Constants.DDZ_PLAYER; ++wChairID) {
			int cbTmpSingleCardCount = AnalyseSinleCardCount(m_cbAllCardData[wChairID], Constants.NORMAL_COUNT, null,
					0);
			if (wChairID != wMeChairID && cbTmpSingleCardCount < cbMinSingleCardCount)
				cbTmpSingleCardCount = cbMinSingleCardCount;
		}

		// 叫一分
		if (cbLargeCardCount >= 3 && cbSingleCardCount < cbMinSingleCardCount - 3)
			return 2;

		// 放弃叫分
		return 255;
	}

	// 出牌测试
	boolean _TestOutAllCard(int wTestUser, int cbWantOutCardData[], int cbWantOutCardCount, int cbAllCardData[][],
			int cbUserCardCount[], boolean bFirstOutCard) {
		// 此递归暂不可用
		// return false ;

		// 朋友ID
		int wFriendID = Constants.DDZ_PLAYER;
		if (wTestUser != m_wBankerUser)
			wFriendID = (wTestUser == ((m_wBankerUser + 1) % Constants.DDZ_PLAYER))
					? (m_wBankerUser + 2) % Constants.DDZ_PLAYER : (m_wBankerUser + 1) % Constants.DDZ_PLAYER;

		// 暂时只处理少数牌
		// for(int wUser=0; wUser<GAME_PLAYER; ++wUser) if(wFriendID!=wUser &&
		// cbUserCardCount[wUser]>10) return false ;

		// m_lRecCount++ ;
		// 防止深层递归
		// if(m_lRecCount>50) return false ;

		int cbWantOutCardType = GetCardType(cbWantOutCardData, cbWantOutCardCount);

		// 出完判断
		if (cbUserCardCount[wTestUser] == cbWantOutCardCount)
			return true;

		// 出牌判断
		try {
			for (int wUser = 0; wUser < Constants.DDZ_PLAYER; ++wUser) {
				if (wUser != wTestUser && wFriendID != wUser) {
					tagOutCardTypeResult_Server CardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
					tagOutCardTypeResult_Server.init(CardTypeResult);
					// ZeroMemory(CardTypeResult,sizeof(CardTypeResult));

					// 出牌分析
					try {
						AnalyseOutCardType(cbAllCardData[wUser], cbUserCardCount[wUser], cbWantOutCardData,
								cbWantOutCardCount, CardTypeResult);
					} catch (Exception e) {
						e.printStackTrace();
						return false;
					}
					for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType)
						if (CardTypeResult[cbCardType].cbCardTypeCount > 0)
							return false;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}

		// 拆炸判断
		int cbAllBombCard[] = new int[Constants.MAX_COUNT];
		int cbAllBombCount = 0;
		cbAllBombCount = GetAllBomCard(cbAllCardData[wTestUser], cbUserCardCount[wTestUser], cbAllBombCard,
				cbAllBombCount);
		if (cbAllBombCount > 0) {
			// 剩余扑克
			int cbRemainCard[] = new int[Constants.MAX_COUNT];
			int cbRemainCardCount;

			Constants.CopyMemory(cbRemainCard, cbAllCardData[wTestUser], cbUserCardCount[wTestUser]);
			cbRemainCardCount = cbUserCardCount[wTestUser];

			RemoveCard(cbWantOutCardData, cbWantOutCardCount, cbRemainCard, cbRemainCardCount);
			cbRemainCardCount -= cbWantOutCardCount;

			// 愚蠢牌型
			if (Constants.CT_FOUR_LINE_TAKE_ONE == cbWantOutCardType
					|| Constants.CT_FOUR_LINE_TAKE_TWO == cbWantOutCardType)
				return false;

			// 只剩炸弹
			if (cbWantOutCardType >= Constants.CT_BOMB_CARD && cbWantOutCardCount == cbUserCardCount[wTestUser])
				return true;

			// 只剩炸弹
			if (cbAllBombCount == cbUserCardCount[wTestUser] && cbWantOutCardType >= Constants.CT_BOMB_CARD)
				return true;

			// 炸弹和一手
			if (cbWantOutCardType >= Constants.CT_BOMB_CARD
					&& GetCardType(cbRemainCard, cbRemainCardCount) != Constants.CT_ERROR
					&& Constants.CT_FOUR_LINE_TAKE_TWO != GetCardType(cbRemainCard, cbRemainCardCount)
					&& Constants.CT_FOUR_LINE_TAKE_ONE != GetCardType(cbRemainCard, cbRemainCardCount))
				return true;

			// 首出牌时不出炸弹
			if (cbWantOutCardType >= Constants.CT_BOMB_CARD && bFirstOutCard) {
				// 地主只剩一手牌
				if (wTestUser != m_wBankerUser && GetCardType(m_cbAllCardData[m_wBankerUser],
						m_cbUserCardCount[m_wBankerUser]) == Constants.CT_ERROR)
					return false;

				int wUndersideOfBanker = (m_wBankerUser + 1) % Constants.DDZ_PLAYER; // 地主下家
				int wUpsideOfBanker = (wUndersideOfBanker + 1) % Constants.DDZ_PLAYER; // 地主上家

				// 闲家只剩一手牌
				if (wTestUser == m_wBankerUser
						&& GetCardType(m_cbAllCardData[wUndersideOfBanker],
								m_cbUserCardCount[wUndersideOfBanker]) == Constants.CT_ERROR
						&& GetCardType(m_cbAllCardData[wUpsideOfBanker],
								m_cbUserCardCount[wUpsideOfBanker]) == Constants.CT_ERROR)
					return false;
			}

			// 拆炸判断
			if (cbWantOutCardType < Constants.CT_FOUR_LINE_TAKE_ONE && cbWantOutCardType != Constants.CT_SINGLE_LINE) {
				for (int i = 0; i < cbWantOutCardCount; ++i)
					for (int j = 0; j < cbAllBombCount; ++j) {
						if (GetCardValue(cbAllBombCard[j]) == GetCardValue(cbWantOutCardData[i]))
							return false;
					}
			}
		}

		if (cbUserCardCount[wTestUser] == 0)
			return true;

		// 递归处理
		try {
			// ASSERT(cbUserCardCount[wTestUser]>=cbWantOutCardCount);
			if (cbUserCardCount[wTestUser] < cbWantOutCardCount)
				return false;
			RemoveCard(cbWantOutCardData, cbWantOutCardCount, cbAllCardData[wTestUser], cbUserCardCount[wTestUser]);
			cbUserCardCount[wTestUser] -= cbWantOutCardCount;

			// 不带大牌
			if (cbWantOutCardType >= Constants.CT_THREE_LINE_TAKE_ONE
					&& cbWantOutCardType <= Constants.CT_FOUR_LINE_TAKE_TWO && !bFirstOutCard) {
				boolean bHaveLargeCard = false;
				for (int i = 3; i < cbWantOutCardCount; ++i)
					if (GetCardLogicValue(cbWantOutCardData[i]) >= 15) {
						bHaveLargeCard = true;
						break;
					}
				if (bHaveLargeCard) {
					for (int i = 0; i < cbUserCardCount[wTestUser]; ++i)
						if (GetCardLogicValue(cbAllCardData[wTestUser][i]) < 15)
							return false;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		if (cbUserCardCount[wTestUser] != 0) {
			tagOutCardTypeResult_Server CardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
			tagOutCardTypeResult_Server.init(CardTypeResult);
			// ZeroMemory(CardTypeResult,sizeof(CardTypeResult));

			// 出牌分析
			try {
				AnalyseOutCardType(cbAllCardData[wTestUser], cbUserCardCount[wTestUser], CardTypeResult);
			} catch (Exception e) {
				e.printStackTrace();
				return false;
			}

			for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType)
				if (CardTypeResult[cbCardType].cbCardTypeCount > 0) {
					for (int lIndex = 0; lIndex < CardTypeResult[cbCardType].cbCardTypeCount; ++lIndex) {
						// 保存数据
						int cbTmpCardData[][] = new int[Constants.DDZ_PLAYER][Constants.MAX_COUNT];
						int cbTmpCardCount[] = new int[Constants.DDZ_PLAYER];
						cbTmpCardData = cbAllCardData.clone();
						Constants.CopyMemory(cbTmpCardCount, cbUserCardCount);

						// 递归分析
						try {
							if (_TestOutAllCard(wTestUser, CardTypeResult[cbCardType].cbCardData[lIndex],
									CardTypeResult[cbCardType].cbEachHandCardCount[lIndex], cbTmpCardData,
									cbTmpCardCount, bFirstOutCard))
								return true;
						} catch (Exception e) {
							e.printStackTrace();
							return false;
						}
					}
				}
		} else
			return true;

		return false;
	}

	// 四带牌型
	boolean AnalyseFourCardType(int cbHandCardData[], int cbHandCardCount, int cbEnemyCardData[], int cbEnemyCardCount,
			tagOutCardResult_Server CardResult) {

		// 牌数判断
		if (cbHandCardCount < 5)
			return false;

		// 对方牌型分析
		if (GetCardType(cbEnemyCardData, cbEnemyCardCount) == Constants.CT_SINGLE) {
			// 对王判断
			if (GetCardLogicValue(cbHandCardData[1]) < 16) {
				// 分析扑克
				tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();
				AnalysebCardData(cbHandCardData, cbHandCardCount, AnalyseResult);

				// 分析牌型
				if (cbHandCardCount != (AnalyseResult.cbFourCount * 4 + AnalyseResult.cbDoubleCount * 2
						+ AnalyseResult.cbSignedCount) || AnalyseResult.cbFourCount <= 0)
					return false;

				// 对方单牌
				if (GetCardType(cbEnemyCardData, cbEnemyCardCount) == Constants.CT_SINGLE) {
					// 个数判断
					if (AnalyseResult.cbSignedCount < 2)
						return false;

					// 大小判断
					if (GetCardLogicValue(AnalyseResult.cbSignedCardData[0]) >= GetCardLogicValue(cbEnemyCardData[0]))
						return false;

					// 四张带两单
					if (AnalyseResult.cbFourCount >= 1 && AnalyseResult.cbSignedCount == 2) {
						// 炸弹索引
						int cbFourCardIndex = (AnalyseResult.cbFourCount - 1) * 4;

						// 返回结果
						CardResult.cbCardCount = 4 + 2;
						Constants.CopyMemory(CardResult.cbResultCard, 0, AnalyseResult.cbFourCardData, cbFourCardIndex,
								4);
						CardResult.cbResultCard[4] = AnalyseResult.cbSignedCardData[0];
						CardResult.cbResultCard[5] = AnalyseResult.cbSignedCardData[1];

						return true;
					}
					// 四张带三单
					else if (AnalyseResult.cbFourCount >= 1 && AnalyseResult.cbSignedCount == 3) {
						// 炸弹索引
						int cbFourCardIndex = (AnalyseResult.cbFourCount - 1) * 4;

						// 返回结果
						CardResult.cbCardCount = 4 + 2;
						Constants.CopyMemory(CardResult.cbResultCard, 0, AnalyseResult.cbFourCardData, cbFourCardIndex,
								4);
						CardResult.cbResultCard[4] = AnalyseResult.cbSignedCardData[1];
						CardResult.cbResultCard[5] = AnalyseResult.cbSignedCardData[2];

						return true;
					}
				} else if (GetCardType(cbEnemyCardData, cbEnemyCardCount) == Constants.CT_DOUBLE) {
				}

			}
			// 对王判断
			else if (GetCardLogicValue(cbHandCardData[1]) == 16) {
				// 分析扑克
				tagAnalyseResult_Server AnalyseResult = new tagAnalyseResult_Server();
				AnalysebCardData(cbHandCardData, cbHandCardCount, AnalyseResult);

				// 分析牌型
				if (cbHandCardCount != (AnalyseResult.cbFourCount * 4 + AnalyseResult.cbDoubleCount * 2
						+ AnalyseResult.cbSignedCount) || AnalyseResult.cbFourCount <= 0)
					return false;

				// 对方单牌
				if (GetCardType(cbEnemyCardData, cbEnemyCardCount) == Constants.CT_SINGLE) {
					// 个数判断
					if (AnalyseResult.cbSignedCount < 4)
						return false;

					// 大小判断
					if (GetCardLogicValue(AnalyseResult.cbSignedCardData[2]) >= GetCardLogicValue(cbEnemyCardData[0]))
						return false;

					// 四张带两单
					if (AnalyseResult.cbFourCount >= 1 && AnalyseResult.cbSignedCount == 4) {
						// 炸弹索引
						int cbFourCardIndex = (AnalyseResult.cbFourCount - 1) * 4;

						// 返回结果
						CardResult.cbCardCount = 4 + 2;
						Constants.CopyMemory(CardResult.cbResultCard, 0, AnalyseResult.cbFourCardData, cbFourCardIndex,
								4);
						CardResult.cbResultCard[4] = AnalyseResult.cbSignedCardData[2];
						CardResult.cbResultCard[5] = AnalyseResult.cbSignedCardData[3];

						return true;
					}
					// 四张带三单
					else if (AnalyseResult.cbFourCount >= 1 && AnalyseResult.cbSignedCount == 5) {
						// 炸弹索引
						int cbFourCardIndex = (AnalyseResult.cbFourCount - 1) * 4;

						// 返回结果
						CardResult.cbCardCount = 4 + 2;
						Constants.CopyMemory(CardResult.cbResultCard, AnalyseResult.cbFourCardData, cbFourCardIndex, 4);
						CardResult.cbResultCard[4] = AnalyseResult.cbSignedCardData[3];
						CardResult.cbResultCard[5] = AnalyseResult.cbSignedCardData[4];

						return true;
					}
				}
			}
		}
		//// 一张大牌带一张
		// else if (GetCardType(cbEnemyCardData, cbEnemyCardCount) == CT_ERROR
		//// && cbEnemyCardCount == 2 )
		// {
		// //对王判断
		// if ( GetCardLogicValue(cbHandCardData[2] ) < 16 )
		// {
		// //分析扑克
		// tagAnalyseResult_Server AnalyseResult ;
		// AnalysebCardData(cbHandCardData, cbHandCardCount, AnalyseResult) ;

		// //分析牌型
		// if ( cbHandCardCount != ( AnalyseResult.cbFourCount * 4 +
		// AnalyseResult.cbDoubleCount * 2 + AnalyseResult.cbSignedCount ) ||
		// AnalyseResult.cbFourCount <= 0 ) return false ;

		// //个数判断
		// if ( AnalyseResult.cbSignedCount < 2 ) return false ;

		// //四张带三单
		// if ( AnalyseResult.cbFourCount >= 1 && AnalyseResult.cbSignedCount ==
		// 3 )
		// {
		// //大小判断
		// if ( GetCardLogicValue(AnalyseResult.cbSignedCardData[0]) >
		// GetCardLogicValue(cbEnemyCardData[0]) ) return false ;

		// //炸弹索引
		// int cbFourCardIndex = ( AnalyseResult.cbFourCount - 1 ) * 4 ;

		// //返回结果
		// CardResult.cbCardCount = 4 + 2 ;
		// CopyMemory(CardResult.cbResultCard, AnalyseResult.cbFourCardData +
		// cbFourCardIndex, 4 ) ;
		// CardResult.cbResultCard[4] = AnalyseResult.cbSignedCardData[1] ;
		// CardResult.cbResultCard[5] = AnalyseResult.cbSignedCardData[2] ;

		// return true ;
		// }
		// }
		// }
		return false;
	}

	// 出牌测试
	boolean TestOutAllCard(int wTestUser, int cbWantOutCardData[], int cbWantOutCardCount, boolean bFirstOutCard) {

		try {
			if (!VerifyOutCard(wTestUser, cbWantOutCardData, cbWantOutCardCount, m_cbAllCardData[wTestUser],
					m_cbUserCardCount[wTestUser], bFirstOutCard)) {
				return false;
			}

			// 模拟递归处理
			if (cbWantOutCardCount != m_cbUserCardCount[wTestUser]) {

				// 初始栈
				m_StackHandCardInfo.InitStack();

				// 第一个元素
				tagHandCardInfo_Server OriginHandCardInfo = new tagHandCardInfo_Server();

				// 手上扑克
				Constants.CopyMemory(OriginHandCardInfo.cbHandCardData, m_cbAllCardData[wTestUser],
						m_cbUserCardCount[wTestUser]);
				OriginHandCardInfo.cbHandCardCount = m_cbUserCardCount[wTestUser];

				// 移除第一手牌
				RemoveCard(cbWantOutCardData, cbWantOutCardCount, OriginHandCardInfo.cbHandCardData,
						OriginHandCardInfo.cbHandCardCount);
				OriginHandCardInfo.cbHandCardCount -= cbWantOutCardCount;

				// 分析扑克
				try {
					AnalyseOutCardType(OriginHandCardInfo.cbHandCardData, OriginHandCardInfo.cbHandCardCount,
							OriginHandCardInfo.CardTypeResult);
				} catch (Exception e) {
					e.printStackTrace();
					return false;
				}

				// 元素压栈
				m_StackHandCardInfo.Push(OriginHandCardInfo);

				// 次数控制
				int lJudgeCount = 0;

				while (!m_StackHandCardInfo.IsEmpty()) {

					// 防止死循环
					if (++lJudgeCount == 100) {

						return false;
					}

					// 栈顶元素
					tagHandCardInfo_Server pTopHandCardInfo = null;
					pTopHandCardInfo = m_StackHandCardInfo.GetTop(pTopHandCardInfo);

					// 合法判断
					// ASSERT(pTopHandCardInfo!=null);
					if (pTopHandCardInfo == null) {
						return false;
					}

					// 牌型数据
					tagOutCardTypeResult_Server[] pOutCardTypeResult = pTopHandCardInfo.CardTypeResult.clone();

					// 禁止的牌型
					pOutCardTypeResult[Constants.CT_FOUR_LINE_TAKE_ONE].cbCardTypeCount = 0;
					pOutCardTypeResult[Constants.CT_FOUR_LINE_TAKE_TWO].cbCardTypeCount = 0;

					// 所有牌型
					boolean bBreakJudge = false;
					boolean bFindLargestCard = false;
					for (int cbOutCardTypeIndx = Constants.CT_SINGLE; cbOutCardTypeIndx <= Constants.CT_MISSILE_CARD
							&& !bBreakJudge; ++cbOutCardTypeIndx) {
						for (int cbHandCardIndx = 0; cbHandCardIndx < pOutCardTypeResult[cbOutCardTypeIndx].cbCardTypeCount
								&& !bBreakJudge; ++cbHandCardIndx) {

							// 是否判断过
							if (pOutCardTypeResult[cbOutCardTypeIndx].cbEachHandCardCount[cbHandCardIndx] == 0) {
								continue;
							}

							// 最大判断
							if (IsLargestCard(wTestUser,
									pOutCardTypeResult[cbOutCardTypeIndx].cbCardData[cbHandCardIndx],
									pOutCardTypeResult[cbOutCardTypeIndx].cbEachHandCardCount[cbHandCardIndx])) {

								// 最后一手
								boolean bIsLastHandCard = pOutCardTypeResult[cbOutCardTypeIndx].cbEachHandCardCount[cbHandCardIndx] == pTopHandCardInfo.cbHandCardCount;
								if (bIsLastHandCard) {
									return true;
								}

								// 是否能出
								if (!VerifyOutCard(wTestUser,
										pOutCardTypeResult[cbOutCardTypeIndx].cbCardData[cbHandCardIndx],
										pOutCardTypeResult[cbOutCardTypeIndx].cbEachHandCardCount[cbHandCardIndx],
										pTopHandCardInfo.cbHandCardData, pTopHandCardInfo.cbHandCardCount,
										bFirstOutCard)) {

									// 表明此牌已经判断过
									pOutCardTypeResult[cbOutCardTypeIndx].cbEachHandCardCount[cbHandCardIndx] = 0;
									continue;
								}

								// 新建栈元素
								tagHandCardInfo_Server NewHandCardInfo = new tagHandCardInfo_Server();

								// 手上扑克
								Constants.CopyMemory(NewHandCardInfo.cbHandCardData, pTopHandCardInfo.cbHandCardData,
										pTopHandCardInfo.cbHandCardCount);
								NewHandCardInfo.cbHandCardCount = pTopHandCardInfo.cbHandCardCount;

								// 移除当前一手
								RemoveCard(pOutCardTypeResult[cbOutCardTypeIndx].cbCardData[cbHandCardIndx],
										pOutCardTypeResult[cbOutCardTypeIndx].cbEachHandCardCount[cbHandCardIndx],
										NewHandCardInfo.cbHandCardData, NewHandCardInfo.cbHandCardCount);
								NewHandCardInfo.cbHandCardCount -= pOutCardTypeResult[cbOutCardTypeIndx].cbEachHandCardCount[cbHandCardIndx];

								// 表明此牌已经判断过
								pOutCardTypeResult[cbOutCardTypeIndx].cbEachHandCardCount[cbHandCardIndx] = 0;

								// 分析扑克
								try {
									AnalyseOutCardType(NewHandCardInfo.cbHandCardData, NewHandCardInfo.cbHandCardCount,
											NewHandCardInfo.CardTypeResult);
								} catch (Exception e) {
									e.printStackTrace();
									return false;
								}

								// 元素压栈
								m_StackHandCardInfo.Push(NewHandCardInfo);

								// 中断循环
								bBreakJudge = true;

								// 设置标识
								bFindLargestCard = true;
							}
							// 当前一手的数目等于手上扑克数目
							else if (pOutCardTypeResult[cbOutCardTypeIndx].cbEachHandCardCount[cbHandCardIndx] == pTopHandCardInfo.cbHandCardCount) {
								return true;
							}
						}
					}

					// 出栈判断
					if (!bFindLargestCard) {
						m_StackHandCardInfo.Pop();
					}
				}
			} else {
				return true;
			}
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}

		return false;
	}

	// 最大判断
	boolean IsLargestCard(int wTestUser, int cbWantOutCardData[], int cbWantOutCardCount) {

		// 朋友ID
		int wFriendID = Constants.DDZ_PLAYER;
		if (wTestUser != m_wBankerUser) {
			wFriendID = (wTestUser == ((m_wBankerUser + 1) % Constants.DDZ_PLAYER))
					? (m_wBankerUser + 2) % Constants.DDZ_PLAYER : (m_wBankerUser + 1) % Constants.DDZ_PLAYER;
		}

		// 出牌判断
		try {
			for (int wUser = 0; wUser < Constants.DDZ_PLAYER; ++wUser) {
				if (wUser != wTestUser && wFriendID != wUser) {
					tagOutCardTypeResult_Server CardTypeResult[] = new tagOutCardTypeResult_Server[12 + 1];
					tagOutCardTypeResult_Server.init(CardTypeResult);
					// 出牌分析
					try {
						AnalyseOutCardType(m_cbAllCardData[wUser], m_cbUserCardCount[wUser], cbWantOutCardData,
								cbWantOutCardCount, CardTypeResult);
					} catch (Exception e) {
						e.printStackTrace();
						return false;
					}

					for (int cbCardType = Constants.CT_SINGLE; cbCardType <= Constants.CT_MISSILE_CARD; ++cbCardType) {
						if (0 < CardTypeResult[cbCardType].cbCardTypeCount) {
							return false;
						}
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}

		return true;
	}

	// 是否能出
	boolean VerifyOutCard(int wTestUser, int cbWantOutCardData[], int cbWantOutCardCount, int cbCurHandCardData[],
			int cbCurHandCardCount, boolean bFirstOutCard) {

		// 朋友ID
		int wFriendID = Constants.DDZ_PLAYER;
		if (wTestUser != m_wBankerUser) {
			wFriendID = (wTestUser == ((m_wBankerUser + 1) % Constants.DDZ_PLAYER))
					? (m_wBankerUser + 2) % Constants.DDZ_PLAYER : (m_wBankerUser + 1) % Constants.DDZ_PLAYER;
		}

		int cbWantOutCardType = GetCardType(cbWantOutCardData, cbWantOutCardCount);

		// 首出判断
		if (bFirstOutCard && cbWantOutCardCount == cbCurHandCardCount) {
			return true;
		}

		// 是否最大
		if (!IsLargestCard(wTestUser, cbWantOutCardData, cbWantOutCardCount)) {
			return false;
		}

		// 拆炸判断
		int cbAllBombCard[] = new int[Constants.MAX_COUNT];
		int cbAllBombCount = 0;
		cbAllBombCount = GetAllBomCard(cbCurHandCardData, cbCurHandCardCount, cbAllBombCard, cbAllBombCount);

		if (0 < cbAllBombCount) {
			// 剩余扑克
			int cbRemainCard[] = new int[Constants.MAX_COUNT];
			int cbRemainCardCount;

			Constants.CopyMemory(cbRemainCard, cbCurHandCardData, cbCurHandCardCount);
			cbRemainCardCount = cbCurHandCardCount;

			RemoveCard(cbWantOutCardData, cbWantOutCardCount, cbRemainCard, cbRemainCardCount);
			cbRemainCardCount -= cbWantOutCardCount;

			// 愚蠢牌型
			if (Constants.CT_FOUR_LINE_TAKE_ONE == cbWantOutCardType
					|| Constants.CT_FOUR_LINE_TAKE_TWO == cbWantOutCardType)
				return false;

			// 只剩炸弹
			if (Constants.CT_BOMB_CARD <= cbWantOutCardType && cbWantOutCardCount == cbCurHandCardCount)
				return true;

			// 只剩炸弹
			if (cbAllBombCount == m_cbUserCardCount[wTestUser] && Constants.CT_BOMB_CARD <= cbWantOutCardType)
				return true;

			// 炸弹和一手
			if (Constants.CT_BOMB_CARD <= cbWantOutCardType
					&& GetCardType(cbRemainCard, cbRemainCardCount) != Constants.CT_ERROR
					&& Constants.CT_FOUR_LINE_TAKE_TWO != GetCardType(cbRemainCard, cbRemainCardCount)
					&& Constants.CT_FOUR_LINE_TAKE_ONE != GetCardType(cbRemainCard, cbRemainCardCount)) {
				return true;
			}

			// 首出牌时不出炸弹
			if (Constants.CT_BOMB_CARD <= cbWantOutCardType && bFirstOutCard) {
				// 地主只剩一手牌
				if (wTestUser != m_wBankerUser && GetCardType(m_cbAllCardData[m_wBankerUser],
						m_cbUserCardCount[m_wBankerUser]) == Constants.CT_ERROR) {
					return false;
				}

				int wUndersideOfBanker = (m_wBankerUser + 1) % Constants.DDZ_PLAYER; // 地主下家
				int wUpsideOfBanker = (wUndersideOfBanker + 1) % Constants.DDZ_PLAYER; // 地主上家

				// 闲家只剩一手牌
				if (wTestUser == m_wBankerUser
						&& GetCardType(m_cbAllCardData[wUndersideOfBanker],
								m_cbUserCardCount[wUndersideOfBanker]) == Constants.CT_ERROR
						&& GetCardType(m_cbAllCardData[wUpsideOfBanker],
								m_cbUserCardCount[wUpsideOfBanker]) == Constants.CT_ERROR) {
					return false;
				}
			}

			// 拆炸判断
			if (cbWantOutCardType < Constants.CT_FOUR_LINE_TAKE_ONE && cbWantOutCardType != Constants.CT_SINGLE_LINE) {
				for (int i = 0; i < cbWantOutCardCount; ++i)
					for (int j = 0; j < cbAllBombCount; ++j) {
						if (GetCardValue(cbAllBombCard[j]) == GetCardValue(cbWantOutCardData[i]))
							return false;
					}
			}
		}

		// 出完判断
		if (cbCurHandCardCount == cbWantOutCardCount) {
			return true;
		}

		if (cbCurHandCardCount == 0) {
			return true;
		}

		try {
			// ASSERT(cbWantOutCardCount <= cbCurHandCardCount);
			if (cbCurHandCardCount < cbWantOutCardCount) {
				return false;
			}

			// 剩余扑克
			int cbRemainCard[] = new int[Constants.MAX_COUNT];
			int cbRemainCardCount;

			Constants.CopyMemory(cbRemainCard, cbCurHandCardData, cbCurHandCardCount);
			cbRemainCardCount = cbCurHandCardCount;

			RemoveCard(cbWantOutCardData, cbWantOutCardCount, cbRemainCard, cbRemainCardCount);
			cbRemainCardCount -= cbWantOutCardCount;

			if (cbRemainCardCount == 0) {
				return false;
			}

			// 不带大牌
			if (Constants.CT_THREE_LINE_TAKE_ONE <= cbWantOutCardType
					&& cbWantOutCardType <= Constants.CT_FOUR_LINE_TAKE_TWO && !bFirstOutCard) {
				boolean bHaveLargeCard = false;
				for (int i = 3; i < cbWantOutCardCount; ++i)
					if (15 <= GetCardLogicValue(cbWantOutCardData[i])) {
						bHaveLargeCard = true;
						break;
					}
				if (bHaveLargeCard) {
					for (int i = 0; i < cbRemainCardCount; ++i) {
						if (GetCardLogicValue(cbRemainCard[i]) < 15) {
							return false;
						}
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}

		return true;
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////////////////////////

}
